summaryrefslogtreecommitdiff
path: root/lib/AnyEvent/Riak/Role/CVCB.pm
diff options
context:
space:
mode:
authorfranck cuny <franck@lumberjaph.net>2010-05-11 11:22:58 +0200
committerfranck cuny <franck@lumberjaph.net>2010-06-08 08:02:41 +0200
commite71ee6fc097b832df6808a4a97f89029d971e196 (patch)
tree65ce4819db1b2ddc104cd20c5d70e5d4136d3920 /lib/AnyEvent/Riak/Role/CVCB.pm
parentupdate tests (diff)
downloadanyevent-riak-e71ee6fc097b832df6808a4a97f89029d971e196.tar.gz
switch to dzil; rename tests; update changelog
Diffstat (limited to '')
-rw-r--r--lib/AnyEvent/Riak/Role/CVCB.pm24
1 files changed, 8 insertions, 16 deletions
diff --git a/lib/AnyEvent/Riak/Role/CVCB.pm b/lib/AnyEvent/Riak/Role/CVCB.pm
index 74684c2..73812c2 100644
--- a/lib/AnyEvent/Riak/Role/CVCB.pm
+++ b/lib/AnyEvent/Riak/Role/CVCB.pm
@@ -1,27 +1,19 @@
package AnyEvent::Riak::Role::CVCB;
-use Moose::Role;
+# ABSTRACT: return a default condvar and callback if none defined
-sub default_cb {
- my ($self, $options) = @_;
- return sub {
- my $res = shift;
- return $res;
- };
-}
+use Moose::Role;
-sub cvcb {
+sub _cvcb {
my ($self, $options) = @_;
- my ($cv, $cb);
- $cv = AE::cv;
- if ($options->{callback}) {
- $cb = delete $options->{callback};
- }
- else {
- $cb = $self->default_cb();
+ my ($cv, $cb) = (AnyEvent->condvar, sub { return @_ });
+ if ($options && @$options) {
+ $cv = pop @$options if UNIVERSAL::isa($options->[-1], 'AnyEvent::CondVar');
+ $cb = pop @$options if ref $options->[-1] eq 'CODE';
}
($cv, $cb);
}
1;
+