summary refs log tree commit diff
path: root/lib/AnyEvent/Riak/Role/CVCB.pm
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--lib/AnyEvent/Riak/Role/CVCB.pm27
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/AnyEvent/Riak/Role/CVCB.pm b/lib/AnyEvent/Riak/Role/CVCB.pm
new file mode 100644
index 0000000..74684c2
--- /dev/null
+++ b/lib/AnyEvent/Riak/Role/CVCB.pm
@@ -0,0 +1,27 @@
+package AnyEvent::Riak::Role::CVCB;
+
+use Moose::Role;
+
+sub default_cb {
+    my ($self, $options) = @_;
+    return sub {
+        my $res = shift;
+        return $res;
+    };
+}
+
+sub cvcb {
+    my ($self, $options) = @_;
+
+    my ($cv, $cb);
+    $cv = AE::cv;
+    if ($options->{callback}) {
+        $cb = delete $options->{callback};
+    }
+    else {
+        $cb = $self->default_cb();
+    }
+    ($cv, $cb);
+}
+
+1;