Class: Riak::BucketProperties
Overview
Provides a predictable and useful interface to bucket properties. Allows reading, reloading, and setting new values for bucket properties.
Instance Attribute Summary collapse
-
#bucket ⇒ Object
readonly
Returns the value of attribute bucket.
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
-
#[](property_name) ⇒ Object
Read a bucket property.
-
#[]=(property_name, value) ⇒ Object
Write a bucket property.
-
#initialize(bucket) ⇒ BucketProperties
constructor
Create a properties object for a bucket (including bucket-typed buckets).
-
#merge!(other) ⇒ Object
Take bucket properties from a given Hash or BucketProperties object.
-
#reload ⇒ Object
Clobber the cached properties, and reload them from Riak.
-
#store ⇒ Object
Write bucket properties and invalidate the cache in this object.
-
#to_hash ⇒ Hash<String, Object>
Convert the cached properties into a hash for merging.
Constructor Details
#initialize(bucket) ⇒ BucketProperties
Create a properties object for a bucket (including bucket-typed buckets).
12 13 14 15 |
# File 'lib/riak/bucket_properties.rb', line 12 def initialize(bucket) @bucket = bucket @client = bucket.client end |
Instance Attribute Details
#bucket ⇒ Object (readonly)
Returns the value of attribute bucket.
8 9 10 |
# File 'lib/riak/bucket_properties.rb', line 8 def bucket @bucket end |
#client ⇒ Object (readonly)
Returns the value of attribute client.
7 8 9 |
# File 'lib/riak/bucket_properties.rb', line 7 def client @client end |
Instance Method Details
#[](property_name) ⇒ Object
Read a bucket property
49 50 51 |
# File 'lib/riak/bucket_properties.rb', line 49 def [](property_name) cached_props[property_name.to_s] end |
#[]=(property_name, value) ⇒ Object
Write a bucket property
56 57 58 59 |
# File 'lib/riak/bucket_properties.rb', line 56 def []=(property_name, value) value = unwrap_index(value) if property_name == 'search_index' cached_props[property_name.to_s] = value end |
#merge!(other) ⇒ Object
Take bucket properties from a given Hash or Riak::BucketProperties object.
36 37 38 |
# File 'lib/riak/bucket_properties.rb', line 36 def merge!(other) cached_props.merge! other end |
#reload ⇒ Object
Clobber the cached properties, and reload them from Riak.
18 19 20 21 22 |
# File 'lib/riak/bucket_properties.rb', line 18 def reload @cached_props = nil cached_props true end |
#store ⇒ Object
Write bucket properties and invalidate the cache in this object.
25 26 27 28 29 30 31 |
# File 'lib/riak/bucket_properties.rb', line 25 def store client.backend do |be| be.bucket_properties_operator.put bucket, cached_props end @cached_props = nil return true end |