Class: Rico::Value
Instance Attribute Summary
Attributes included from Object
Class Method Summary collapse
-
.resolve(robject) ⇒ Object
Resolve conflict between one or more RObject siblings.
Instance Method Summary collapse
-
#setnx(value) ⇒ Object
Sets the value if it does not exist.
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 |