Class: Riak::BucketTyped::Bucket
- Inherits:
-
Riak::Bucket
- Object
- Riak::Bucket
- Riak::BucketTyped::Bucket
- Defined in:
- lib/riak/bucket_typed/bucket.rb
Overview
A bucket that has a Riak::BucketType attached to it. Normally created using the Riak::BucketType#bucket method. Inherits most of its behavior from the Riak::Bucket class.
Constant Summary
Constants inherited from Riak::Bucket
Riak::Bucket::SEARCH_PRECOMMIT_HOOK
Instance Attribute Summary collapse
-
#type ⇒ BucketType
readonly
The bucket type used with this bucket.
Attributes inherited from Riak::Bucket
Instance Method Summary collapse
- #==(other) ⇒ Object
- #clear_props ⇒ Object
-
#delete(key, options = { }) ⇒ Object
Deletes a key from the bucket.
-
#get(key, options = { }) ⇒ Riak::RObject
(also: #[])
Retrieve an object from within the bucket type and bucket.
-
#get_index(index, query, options = { }) ⇒ Array<String>
Queries a secondary index on the bucket-typed bucket.
-
#initialize(client, name, type) ⇒ Bucket
constructor
Create a bucket-typed bucket manually.
-
#inspect ⇒ String
A friendly representation of this bucket-typed bucket.
-
#keys(options = { }) {|Array<String>| ... } ⇒ Array<String>
Retrieves a list of keys in this bucket.
-
#needs_type? ⇒ Boolean
Does this Bucket have a non-default bucket type?.
-
#pretty_print(pp) ⇒ Object
Pretty prints the bucket for ‘pp` or `pry`.
- #props ⇒ Object
- #props=(new_props) ⇒ Object
Methods inherited from Riak::Bucket
#allow_mult, #allow_mult=, #counter, #disable_index!, #enable_index!, #exists?, #get_many, #get_or_new, #get_preflist, #is_indexed?, #n_value, #n_value=, #new
Methods included from Util::Translation
Methods included from Util::String
Constructor Details
#initialize(client, name, type) ⇒ Bucket
Create a bucket-typed bucket manually.
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/riak/bucket_typed/bucket.rb', line 22 def initialize(client, name, type) if type.is_a? String type = client.bucket_type type elsif !(type.is_a? BucketType) raise ArgumentError, t('argument_error.bucket_type', bucket_type: type) end @type = type super client, name end |
Instance Attribute Details
#type ⇒ BucketType (readonly)
Returns the bucket type used with this bucket.
16 17 18 |
# File 'lib/riak/bucket_typed/bucket.rb', line 16 def type @type end |
Instance Method Details
#==(other) ⇒ Object
119 120 121 122 123 |
# File 'lib/riak/bucket_typed/bucket.rb', line 119 def ==(other) return false unless self.class == other.class return false unless self.type == other.type super end |
#clear_props ⇒ Object
85 86 87 88 |
# File 'lib/riak/bucket_typed/bucket.rb', line 85 def clear_props @props = nil @client.clear_bucket_props(self, type: self.type.name) end |
#delete(key, options = { }) ⇒ Object
Deletes a key from the bucket
54 55 56 |
# File 'lib/riak/bucket_typed/bucket.rb', line 54 def delete(key, = { }) super key, o() end |
#get(key, options = { }) ⇒ Riak::RObject Also known as: []
Retrieve an object from within the bucket type and bucket.
40 41 42 43 44 |
# File 'lib/riak/bucket_typed/bucket.rb', line 40 def get(key, = { }) object = super key, o() object.bucket = self return object end |
#get_index(index, query, options = { }) ⇒ Array<String>
This will only work if your Riak installation supports 2I.
Queries a secondary index on the bucket-typed bucket.
108 109 110 |
# File 'lib/riak/bucket_typed/bucket.rb', line 108 def get_index(index, query, = { }) super index, query, o() end |
#inspect ⇒ String
Returns a friendly representation of this bucket-typed bucket.
71 72 73 |
# File 'lib/riak/bucket_typed/bucket.rb', line 71 def inspect "#<Riak::BucketTyped::Bucket {#{ type.name }/#{ name }}>" end |
#keys(options = { }) {|Array<String>| ... } ⇒ Array<String>
This operation has serious performance implications and should not be used in production applications.
Retrieves a list of keys in this bucket. If a block is given, keys will be streamed through the block (useful for large buckets). When streaming, results of the operation will not be returned to the caller.
66 67 68 |
# File 'lib/riak/bucket_typed/bucket.rb', line 66 def keys( = { }, &block) super o(), &block end |
#needs_type? ⇒ Boolean
Does this Riak::BucketTyped::Bucket have a non-default bucket type?
114 115 116 117 |
# File 'lib/riak/bucket_typed/bucket.rb', line 114 def needs_type? return true unless type.default? return false end |
#pretty_print(pp) ⇒ Object
Pretty prints the bucket for ‘pp` or `pry`.
91 92 93 94 95 96 97 98 99 |
# File 'lib/riak/bucket_typed/bucket.rb', line 91 def pretty_print(pp) pp.object_group self do pp.breakable pp.text "bucket_type=" type.pretty_print(pp) pp.breakable pp.text "name=#{name}" end end |
#props ⇒ Object
81 82 83 |
# File 'lib/riak/bucket_typed/bucket.rb', line 81 def props @props ||= @client.get_bucket_props(self, type: self.type.name) end |
#props=(new_props) ⇒ Object
75 76 77 78 79 |
# File 'lib/riak/bucket_typed/bucket.rb', line 75 def props=(new_props) raise ArgumentError, t('hash_type', hash: new_props.inspect) unless new_props.is_a? Hash complete_props = props.merge new_props @client.set_bucket_props(self, complete_props, self.type.name) end |