Module: Rico::Object

Extended by:
Forwardable
Included in:
Collection, Counter, Value
Defined in:
lib/rico/object.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#bucketObject

Returns the value of attribute bucket.



7
8
9
# File 'lib/rico/object.rb', line 7

def bucket
  @bucket
end

#keyObject

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

Returns:

  • (Boolean)


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, options={})
  @bucket, @key = bucket, key
  options.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