summaryrefslogtreecommitdiff
path: root/lib/Net/Riak/Object.pm
diff options
context:
space:
mode:
authorMainframe2008 <thg.bot@gmail.com>2013-02-01 12:46:04 +0100
committerMainframe2008 <thg.bot@gmail.com>2013-02-01 12:46:04 +0100
commit2fd683a151a9a4bdaf64d44468fbde4fa5226602 (patch)
tree30828b26fec5018a0185b08cd44660a8a2dfbc2f /lib/Net/Riak/Object.pm
parentAdded comments for searching using secondary indexes (diff)
downloadnet-riak-2fd683a151a9a4bdaf64d44468fbde4fa5226602.tar.gz
Added support for searching with secondary indexes
Diffstat (limited to 'lib/Net/Riak/Object.pm')
-rw-r--r--lib/Net/Riak/Object.pm29
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/Net/Riak/Object.pm b/lib/Net/Riak/Object.pm
index 7148d4f..8e48dcb 100644
--- a/lib/Net/Riak/Object.pm
+++ b/lib/Net/Riak/Object.pm
@@ -5,6 +5,7 @@ package Net::Riak::Object;
use Moose;
use Scalar::Util;
use Net::Riak::Link;
+use Data::Dumper;
with 'Net::Riak::Role::Replica' => {keys => [qw/r w dw/]};
with 'Net::Riak::Role::Base' => {classes =>
@@ -23,6 +24,9 @@ has vtag => (is => 'rw', isa => 'Str');
has content_type => (is => 'rw', isa => 'Str', default => 'application/json');
has location => ( is => 'rw', isa => 'Str' );
has _jsonize => (is => 'rw', isa => 'Bool', lazy => 1, default => 1);
+
+has i2indexes => ( is => 'rw', isa => 'HashRef' );
+
has links => (
traits => ['Array'],
is => 'rw',
@@ -69,6 +73,31 @@ sub store {
$self->client->store_object($w, $dw, $self);
}
+sub i2index {
+ my($self, $args) = @_;
+
+ if ( defined($args) ) {
+ my %args = %{$args};
+ my $ref = undef;
+ if ( defined($self->i2indexes) ) { $ref = $self->i2indexes; }
+ foreach my $i (keys %args)
+ {
+
+ #$i = lc($i);
+ print $i,"\n";
+ if ( defined($args{$i}) && length($args{$i}) > 0 )
+ {
+ $ref->{$i} = $args{$i};
+
+ } else {
+ delete $ref->{$i};
+ }
+ }
+ $self->i2indexes($ref);
+ }
+ $self->i2indexes;
+}
+
sub status {
my ($self) = @_;
warn "DEPRECATED: status method will be removed in the 0.17 release, please use ->client->status.";