| 1 | package Data::Riak::Request::Ping; | ||
| 2 | { | ||
| 3 | $Data::Riak::Request::Ping::VERSION = '2.0'; | ||
| 4 | } | ||
| 5 | |||
| 6 | use Moose; | ||
| 7 | use Data::Riak::Result::SingleValue; | ||
| 8 | use namespace::autoclean; | ||
| 9 | |||
| 10 | sub as_http_request_args { | ||
| 11 | my ($self) = @_; | ||
| 12 | |||
| 13 | return { | ||
| 14 | method => 'GET', | ||
| 15 | uri => 'ping', | ||
| 16 | }; | ||
| 17 | } | ||
| 18 | |||
| 19 | sub _build_http_exception_classes { | ||
| 20 | return { | ||
| 21 | # This is a bit of a hack. Maybe we want to allow predicate functions to | ||
| 22 | # be provided, or at least regexen or some such. | ||
| 23 | (map { ($_ => undef) } 500 .. 599), | ||
| 24 | }; | ||
| 25 | } | ||
| 26 | |||
| 27 | sub _mangle_retval { | ||
| 28 | my ($self, $res) = @_; | ||
| 29 | $res->status_code == 200 ? 1 : 0 | ||
| 30 | } | ||
| 31 | |||
| 32 | with 'Data::Riak::Request', | ||
| 33 | 'Data::Riak::Request::WithHTTPExceptionHandling'; | ||
| 34 | |||
| 35 | has '+result_class' => ( | ||
| 36 | default => Data::Riak::Result::SingleValue::, | ||
| 37 | ); | ||
| 38 | |||
| 39 | __PACKAGE__->meta->make_immutable; | ||
| 40 | |||
| 41 | 1; | ||
| 42 | |||
| 43 | __END__ |