Class: Rico::Value

Inherits:
Object
  • Object
show all
Includes:
Object
Defined in:
lib/rico/value.rb

Instance Attribute Summary

Attributes included from Object

#bucket, #key

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Object

#exists?, #initialize, #mutate

Class Method Details

.resolve(robject) ⇒ Object

Resolve conflict between one or more RObject siblings

This currently just returns the first sibling

robjects - array of RObjects to resolve

Returns a single RObject result or nil



38
39
40
41
42
# File 'lib/rico/value.rb', line 38

def self.resolve(robject)
  obj = Riak::RObject.new(robject.bucket, robject.key)
  obj.data = robject.siblings.first.data
  obj
end

Instance Method Details

#setnx(value) ⇒ Object

Sets the value if it does not exist

value - the value to store

Returns true if stored, false if not



22
23
24
25
26
27
28
29
# File 'lib/rico/value.rb', line 22

def setnx(value)
  if exists?
    false
  else
    set value
    true
  end
end