class Riak::BucketTyped::Bucket
A bucket that has a {BucketType} attached to it. Normally created using the {BucketType#bucket} method. Inherits most of its behavior from the {Riak::Bucket} class.
Attributes
@return [BucketType] the bucket type used with this bucket
Public Class Methods
Create a bucket-typed bucket manually. @param [Client] client the {Riak::Client} for this bucket @param [String] name the name of this bucket @param [BucketType,String] type the bucket type of this bucket
Riak::Bucket::new
# 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
Public Instance Methods
# 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
# File lib/riak/bucket_typed/bucket.rb, line 85 def clear_props @props = nil @client.clear_bucket_props(self, type: self.type.name) end
Deletes a key from the bucket @param [String] key the key to delete @param [Hash] options quorum options @option options [Fixnum] :rw - the read/write quorum for the
delete
@option options [String] :vclock - the vector clock of the
object being deleted
Riak::Bucket#delete
# File lib/riak/bucket_typed/bucket.rb, line 54 def delete(key, options = { }) super key, o(options) end
Retrieve an object from within the bucket type and bucket. @param [String] key the key of the object to retrieve @param [Hash] options query parameters for the request @option options [Fixnum] :r - the read quorum for the request - how many nodes should concur on the read @return [Riak::RObject] the object @raise [FailedRequest] if the object is not found or some other error occurs
Riak::Bucket#get
# File lib/riak/bucket_typed/bucket.rb, line 40 def get(key, options = { }) object = super key, o(options) object.bucket = self return object end
Queries a secondary index on the bucket-typed bucket. @note This will only work if your Riak
installation supports 2I. @param [String] index the name of the index @param [String,Integer,Range] query the value of the index, or a
Range of values to query
@return [Array<String>] a list of keys that match the index
query
Riak::Bucket#get_index
# File lib/riak/bucket_typed/bucket.rb, line 108 def get_index(index, query, options = { }) super index, query, o(options) end
@return [String] a friendly representation of this bucket-typed bucket
# File lib/riak/bucket_typed/bucket.rb, line 71 def inspect "#<Riak::BucketTyped::Bucket {#{ type.name }/#{ name }}>" end
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. @yield [Array<String>] a list of keys from the current chunk @return [Array<String>] Keys in this bucket @note This operation has serious performance implications and
should not be used in production applications.
Riak::Bucket#keys
# File lib/riak/bucket_typed/bucket.rb, line 66 def keys(options = { }, &block) super o(options), &block end
Does this {BucketTyped::Bucket} have a non-default bucket type? @return [Boolean] true if this bucket has a non-default type.
# File lib/riak/bucket_typed/bucket.rb, line 114 def needs_type? return true unless type.default? return false end
Pretty prints the bucket for `pp` or `pry`.
# 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
# File lib/riak/bucket_typed/bucket.rb, line 81 def props @props ||= @client.get_bucket_props(self, type: self.type.name) end
# 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
Private Instance Methods
merge in the type name with options
# File lib/riak/bucket_typed/bucket.rb, line 127 def o(options) { type: type.name }.merge options end