lib/riak/crdt/set.rb in riak-client-2.2.0.pre1 vs lib/riak/crdt/set.rb in riak-client-2.2.0
- old
+ new
@@ -4,11 +4,11 @@
# A distributed set containing strings, using the Riak 2 Data Types feature.
#
# Uses the Ruby standard library `::Set` frequently, so the full class names will
# be used frequently.
class Set < Base
-
+
# Create a set 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
@@ -17,16 +17,16 @@
# @param bucket [Bucket] the {Riak::Bucket} for this set
# @param [String, nil] key The name of the set. A nil key makes
# Riak assign a key.
# @param [String] bucket_type The optional bucket type for this set.
# @param options [Hash]
- def initialize(bucket, key, bucket_type=nil, options={})
+ def initialize(bucket, key, bucket_type = nil, options = {})
super(bucket, key, bucket_type || :set, options)
end
# Yields a `BatchSet` to proxy multiple set operations into a single
- # Riak update. The `BatchSet` has the same methods as this
+ # Riak update. The `BatchSet` has the same methods as this
# {Riak::Crdt::Set}.
#
# @yieldparam batch_set [BatchSet] collects set operations
def vivify(value)
value.each(&:freeze)
@@ -36,11 +36,11 @@
def batch
batcher = BatchSet.new self
yield batcher
-
+
operate batcher.operations
end
# Gets the current set members from Riak if necessary, and return the
# stdlib `::Set` of them.
@@ -51,11 +51,11 @@
reload if dirty?
@members
end
alias :value :members
-
+
# Cast this {Riak::Crdt::Set} to a Ruby {Array}.
#
# @return [Array] array of set members
def to_a
members.to_a
@@ -65,11 +65,11 @@
#
# @return [Boolean] if the structure is empty
def empty?
members.empty?
end
-
+
# Check to see if a given string is present in this data structure.
#
# @param [String] candidate string to check for inclusion in this structure
# @return [Boolean] if the structure includes
def include?(candidate)
@@ -78,25 +78,25 @@
# Add a {String} to the {Riak::Crdt::Set}
#
# @param [String] element the element to add to the set
# @param [Hash] options
- def add(element, options={})
+ def add(element, options = {})
operate operation(:add, element), options
end
# Remove a {String} from the {Riak::Crdt::Set}
#
# @param [String] element to remove from the set
# @param [Hash] options
- def remove(element, options={})
+ def remove(element, options = {})
raise CrdtError::SetRemovalWithoutContextError unless context?
operate operation(:remove, element), options
end
alias :delete :remove
-
+
def pretty_print(pp)
super pp do
pp.comma_breakable
pp.pp to_a
end
@@ -118,10 +118,10 @@
def initialize(base)
@base = base
@adds = ::Set.new
@removes = ::Set.new
end
-
+
def add(element)
@adds.add element
end
def remove(element)