Class: Riak::BucketType
- Includes:
- Util::String
- Defined in:
- lib/riak/bucket_type.rb
Overview
A representation of a bucket type
Constant Summary collapse
- DEFAULT_NAME =
The name of Riak’s default bucket type.
'default'
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#bucket(bucket_name) ⇒ Object
Get a bucket of this type.
-
#data_type_class ⇒ Class<Riak::Crdt::Base>
Return the data type used for handling the CRDT stored in this bucket type.
-
#default? ⇒ Boolean
Is this bucket type the default?.
-
#initialize(client, name) ⇒ BucketType
constructor
Create a bucket type object manually.
-
#pretty_print(pp) ⇒ Object
Pretty prints the bucket for ‘pp` or `pry`.
-
#properties ⇒ Hash<Symbol,Object>
(also: #props)
Get the properties of this bucket type.
Methods included from Util::String
Constructor Details
#initialize(client, name) ⇒ BucketType
Create a bucket type object manually.
18 19 20 |
# File 'lib/riak/bucket_type.rb', line 18 def initialize(client, name) @client, @name = client, name end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
10 11 12 |
# File 'lib/riak/bucket_type.rb', line 10 def client @client end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/riak/bucket_type.rb', line 10 def name @name end |
Instance Method Details
#==(other) ⇒ Object
73 74 75 76 77 |
# File 'lib/riak/bucket_type.rb', line 73 def ==(other) return false unless self.class == other.class return false unless self.client == other.client return equal_bytes?(self.name, other.name) end |
#bucket(bucket_name) ⇒ Object
Get a bucket of this type
30 31 32 |
# File 'lib/riak/bucket_type.rb', line 30 def bucket(bucket_name) BucketTyped::Bucket.new client, bucket_name, self end |
#data_type_class ⇒ Class<Riak::Crdt::Base>
Return the data type used for handling the CRDT stored in this bucket type. Returns ‘nil` for a non-CRDT bucket type.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/riak/bucket_type.rb', line 58 def data_type_class return nil unless dt = properties[:datatype] parent = Riak::Crdt case dt when 'counter' parent::Counter when 'map' parent::Map when 'set' parent::Set else raise CrdtError::UnrecognizedDataType.new dt end end |
#default? ⇒ Boolean
Is this bucket type the default?
24 25 26 |
# File 'lib/riak/bucket_type.rb', line 24 def default? name == DEFAULT_NAME end |
#pretty_print(pp) ⇒ Object
Pretty prints the bucket for ‘pp` or `pry`.
35 36 37 38 39 40 |
# File 'lib/riak/bucket_type.rb', line 35 def pretty_print(pp) pp.object_group self do pp.breakable pp.text "name=#{name}" end end |