Module: Rico::Object
Instance Attribute Summary collapse
-
#bucket ⇒ Object
Returns the value of attribute bucket.
-
#key ⇒ Object
Returns the value of attribute key.
Instance Method Summary collapse
-
#exists? ⇒ Boolean
Determine whether an object exists or not.
-
#initialize(bucket, key, options = {}) ⇒ Object
Initialize an object with a bucket and key.
-
#mutate(value) ⇒ Object
Sets a new value on the object and stores it.
Instance Attribute Details
#bucket ⇒ Object
Returns the value of attribute bucket.
7 8 9 |
# File 'lib/rico/object.rb', line 7 def bucket @bucket end |
#key ⇒ Object
Returns the value of attribute key.
7 8 9 |
# File 'lib/rico/object.rb', line 7 def key @key end |
Instance Method Details
#exists? ⇒ Boolean
Determine whether an object exists or not
Returns true or false
33 34 35 |
# File 'lib/rico/object.rb', line 33 def exists? Rico.bucket(@bucket).exists? @key end |
#initialize(bucket, key, options = {}) ⇒ Object
Initialize an object with a bucket and key
bucket - the name of the bucket (not prefixed by a namespace) key - the name of the key
Returns nothing
15 16 17 18 |
# File 'lib/rico/object.rb', line 15 def initialize(bucket, key, ={}) @bucket, @key = bucket, key .each {|k,v| send("#{k}=", v)} end |
#mutate(value) ⇒ Object
Sets a new value on the object and stores it
value - new value to set
Returns the result of the store operation
25 26 27 28 |
# File 'lib/rico/object.rb', line 25 def mutate(value) riak_object.data = value store end |