Permalink
Browse files

fix store and fetch

  • Loading branch information...
fcuny committed Apr 11, 2010
1 parent c9814bd commit 61c5d22e63d49decaf2ea150fbb0870a7e57944f
Showing with 16 additions and 4 deletions.
  1. +14 −2 lib/AnyEvent/Riak.pm
  2. +2 −2 t/basic.t
View
@@ -184,7 +184,12 @@ sub fetch {
),
headers => $self->_build_headers( $options{parameters} ),
sub {
- $cv->send( $cb->(@_) );
+ my ($body, $headers) = @_;
+ if ($body && $headers->{Status} == 200) {
+ $cv->send( $cb->(JSON::decode_json($body)) );
+ }else{
+ $cv->send( $cb->(0) );
+ }
}
);
$cv;
@@ -212,7 +217,14 @@ sub store {
headers => $self->_build_headers( $options{parameters} ),
body => $json,
sub {
- $cv->send( $cb->(@_) );
+ my ($body, $headers) = @_;
+ my $result;
+ if ($headers->{Status} == 204) {
+ $result = $body ? JSON::decode_json($body) : 1;
+ }else{
+ $result = 0;
+ }
+ $cv->send( $cb->($result) );
}
);
$cv;
View
@@ -65,8 +65,8 @@ my $value = {
ok my $res = $riak->store('foo', 'bar', $value)->recv, 'set a new key';
-# ok $res = $riak->fetch( 'foo', 'bar' )->recv, 'fetch our new key';
-# is_deeply $res, $value, 'value is ok';
+ok $res = $riak->fetch( 'foo', 'bar' )->recv, 'fetch our new key';
+is_deeply $res, $value, 'value is ok';
# ok $res = $riak->delete( 'foo', 'bar' )->recv, 'delete our key';
# ok my $store_w_cb = $riak->store(

0 comments on commit 61c5d22

Please sign in to comment.