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!, #exist_many, #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.
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/riak/bucket_typed/bucket.rb', line 36 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.
30 31 32 |
# File 'lib/riak/bucket_typed/bucket.rb', line 30 def type @type end |
Instance Method Details
#==(other) ⇒ Object
133 134 135 136 137 |
# File 'lib/riak/bucket_typed/bucket.rb', line 133 def ==(other) return false unless self.class == other.class return false unless self.type == other.type super end |
#clear_props ⇒ Object
99 100 101 102 |
# File 'lib/riak/bucket_typed/bucket.rb', line 99 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
68 69 70 |
# File 'lib/riak/bucket_typed/bucket.rb', line 68 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.
54 55 56 57 58 |
# File 'lib/riak/bucket_typed/bucket.rb', line 54 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.
122 123 124 |
# File 'lib/riak/bucket_typed/bucket.rb', line 122 def get_index(index, query, = { }) super index, query, o() end |
#inspect ⇒ String
Returns a friendly representation of this bucket-typed bucket.
85 86 87 |
# File 'lib/riak/bucket_typed/bucket.rb', line 85 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.
80 81 82 |
# File 'lib/riak/bucket_typed/bucket.rb', line 80 def keys( = { }, &block) super o(), &block end |
#needs_type? ⇒ Boolean
Does this Riak::BucketTyped::Bucket have a non-default bucket type?
128 129 130 131 |
# File 'lib/riak/bucket_typed/bucket.rb', line 128 def needs_type? return true unless type.default? return false end |
#pretty_print(pp) ⇒ Object
Pretty prints the bucket for ‘pp` or `pry`.
105 106 107 108 109 110 111 112 113 |
# File 'lib/riak/bucket_typed/bucket.rb', line 105 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
95 96 97 |
# File 'lib/riak/bucket_typed/bucket.rb', line 95 def props @props ||= @client.get_bucket_props(self, type: self.type.name) end |
#props=(new_props) ⇒ Object
89 90 91 92 93 |
# File 'lib/riak/bucket_typed/bucket.rb', line 89 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 |