Module: Ripple::Document::BucketAccess
- Defined in:
- lib/ripple/document/bucket_access.rb
Overview
Similar to ActiveRecord’s tables or MongoMapper’s collections, we provide a sane default bucket in which to store your documents.
Instance Method Summary collapse
-
#bucket ⇒ Riak::Bucket
The bucket assigned to this class.
-
#bucket_name ⇒ String
The bucket name assigned to the document class.
-
#bucket_name=(value) ⇒ Object
Set the bucket name for this class and its subclasses.
Instance Method Details
#bucket ⇒ Riak::Bucket
Returns The bucket assigned to this class.
14 15 16 |
# File 'lib/ripple/document/bucket_access.rb', line 14 def bucket Ripple.client.bucket(bucket_name) end |
#bucket_name ⇒ String
Returns The bucket name assigned to the document class. Subclasses will inherit their bucket name from their parent class unless they redefine it.
9 10 11 |
# File 'lib/ripple/document/bucket_access.rb', line 9 def bucket_name superclass.respond_to?(:bucket_name) ? superclass.bucket_name : model_name.plural end |
#bucket_name=(value) ⇒ Object
Set the bucket name for this class and its subclasses.
20 21 22 |
# File 'lib/ripple/document/bucket_access.rb', line 20 def bucket_name=(value) (class << self; self; end).send(:define_method, :bucket_name){ value } end |