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

type[R]

@return [BucketType] the bucket type used with this bucket

Public Class Methods

new(client, name, type) click to toggle source

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

Calls superclass method 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

==(other) click to toggle source
Calls superclass method Riak::Bucket#==
# File lib/riak/bucket_typed/bucket.rb, line 108
def ==(other)
  return false unless self.class == other.class
  return false unless self.type == other.type
  super
end
[](key, options = { })
Alias for: get
clear_props() click to toggle source
# 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 = { }) click to toggle source

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
Calls superclass method Riak::Bucket#delete
# File lib/riak/bucket_typed/bucket.rb, line 54
def delete(key, options = {  })
  super key, o(options)
end
get(key, options = { }) click to toggle source

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

Calls superclass method 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
Also aliased as: []
inspect() click to toggle source

@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
keys(options = { }, &block) click to toggle source

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.
Calls superclass method Riak::Bucket#keys
# File lib/riak/bucket_typed/bucket.rb, line 66
def keys(options = {  }, &block)
  super o(options), &block
end
needs_type?() click to toggle source

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 103
def needs_type?
  return true unless type.default?
  return false
end
pretty_print(pp) click to toggle source

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
props() click to toggle source
# 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) click to toggle source
# 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

o(options) click to toggle source

merge in the type name with options

# File lib/riak/bucket_typed/bucket.rb, line 116
def o(options)
  { type: type.name }.merge options
end