lib/riak/crdt/map.rb in riak-client-2.2.0.pre1 vs lib/riak/crdt/map.rb in riak-client-2.2.0
- old
+ new
@@ -14,14 +14,14 @@
# to a Ruby {Hash}
# * {InnerFlag}: a boolean value inside a map
# * {InnerRegister}: a {String} value inside a map
# * {InnerCounter}: a {Riak::Crdt::Counter}, but inside a map
# * {InnerSet}: a {Riak::Crdt::Set}, but inside a map
- #
+ #
class Map < Base
attr_reader :counters, :flags, :maps, :registers, :sets
-
+
# Create a map instance. The bucket type is determined by the first of
# these sources:
#
# 1. The `bucket_type` String argument
# 2. A {BucketTyped::Bucket} as the `bucket` argument
@@ -31,36 +31,36 @@
# @param [String, nil] key The name of the map. A nil key makes
# Riak assign a key.
# @param [String] bucket_type The optional bucket type for this map.
# The default is in `Crdt::Base::DEFAULT_BUCKET_TYPES[:map]`.
# @param options [Hash]
- def initialize(bucket, key, bucket_type=nil, options={})
+ def initialize(bucket, key, bucket_type = nil, options = {})
super(bucket, key, bucket_type || :map, options)
if key
- initialize_collections
+ initialize_collections
else
initialize_blank_collections
end
end
- # Maps are frequently updated in batches. Use this method to get a
+ # Maps are frequently updated in batches. Use this method to get a
# {BatchMap} to turn multiple operations into a single Riak update
# request.
#
- # @yieldparam batch_map [BatchMap] collects updates and other operations
+ # @yieldparam batch_map [BatchMap] collects updates and other operations
def batch(*args)
batch_map = BatchMap.new self
yield batch_map
write_operations batch_map.operations, *args
end
# This method *for internal use only* is used to collect oprations from
# disparate sources to provide a user-friendly API.
- #
+ #
# @api private
def operate(operation, *args)
batch *args do |m|
m.operate operation
end
@@ -81,20 +81,20 @@
[k, send(k).to_value_h]
end.to_h
end
alias :value :to_value_h
-
+
private
def vivify(data)
@counters = TypedCollection.new InnerCounter, self, data[:counters]
@flags = TypedCollection.new InnerFlag, self, data[:flags]
@maps = TypedCollection.new InnerMap, self, data[:maps]
@registers = TypedCollection.new InnerRegister, self, data[:registers]
@sets = TypedCollection.new InnerSet, self, data[:sets]
end
- def initialize_collections(data={})
+ def initialize_collections(data = {})
reload if dirty?
end
def initialize_blank_collections
vivify counters: {}, flags: {}, maps: {}, registers: {}, sets: {}