Skip to content

Commit

Permalink
Document common bucket properties.
Browse files Browse the repository at this point in the history
  • Loading branch information
seancribbs committed Jul 29, 2010
1 parent 24aa369 commit 1ab2af8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
30 changes: 24 additions & 6 deletions riak-client/lib/riak/bucket.rb
Expand Up @@ -26,10 +26,6 @@ class Bucket
# @return [String] the bucket name
attr_reader :name

# @return [Hash] Internal Riak bucket properties.
attr_reader :props
alias_attribute :properties, :props

# Create a Riak bucket manually.
# @param [Client] client the {Riak::Client} for this bucket
# @param [String] name the name of the bucket
Expand Down Expand Up @@ -75,18 +71,40 @@ def keys(options={})
@keys
end


# Sets internal properties on the bucket
# Note: this results in a request to the Riak server!
# @param [Hash] properties new properties for the bucket
# @return [Hash] the properties that were accepted
# @raise [FailedRequest] if the new properties were not accepted by the Riak server
# @option properties [Fixnum] :n_val (3) The N value (replication factor)
# @option properties [true,false] :allow_mult (false) Whether to permit object siblings
# @option properties [true,false] :last_write_wins (false) Whether to ignore vclocks
# @option properties [Array<Hash>] :precommit ([]) precommit hooks
# @option properties [Array<Hash>] :postcommit ([])postcommit hooks
# @option properties [Fixnum,String] :r ("quorum") read quorum (numeric or
# symbolic)
# @option properties [Fixnum,String] :w ("quorum") write quorum (numeric or
# symbolic)
# @option properties [Fixnum,String] :dw ("quorum") durable write quorum
# (numeric or symbolic)
# @option properties [Fixnum,String] :rw ("quorum") delete quorum (numeric or
# symbolic)
# @return [Hash] the merged bucket properties
# @raise [FailedRequest] if the new properties were not accepted by the Riakserver
# @see #n_value, #allow_mult, #r, #w, #dw, #rw
def props=(properties)
raise ArgumentError, t("hash_type", :hash => properties.inspect) unless Hash === properties
body = {'props' => properties}.to_json
@client.http.put(204, @client.prefix, escape(name), body, {"Content-Type" => "application/json"})
@props.merge!(properties)
end

# @return [Hash] Internal Riak bucket properties.
# @see #props=
def props
@props
end
alias_attribute :properties, :props

# Retrieve an object from within the bucket.
# @param [String] key the key of the object to retrieve
# @param [Hash] options query parameters for the request
Expand Down
2 changes: 1 addition & 1 deletion ripple/lib/ripple/associations.rb
Expand Up @@ -199,7 +199,7 @@ def using
@using ||= options[:using] || (embeddable? ? :embedded : :linked)
end

# @raises [ArgumentError] if the value does not match the class of the association
# @raise [ArgumentError] if the value does not match the class of the association
def verify_type!(value)
unless type_matches?(value)
raise ArgumentError.new(t('invalid_association_value',
Expand Down

0 comments on commit 1ab2af8

Please sign in to comment.