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

Instance Method Details

#bucketRiak::Bucket

Returns The bucket assigned to this class.

Returns:

  • (Riak::Bucket)

    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_nameString

Returns The bucket name assigned to the document class. Subclasses will inherit their bucket name from their parent class unless they redefine it.

Returns:

  • (String)

    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.

Parameters:

  • value (String)

    the new bucket name



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