class Riak::Crdt::Set::BatchSet

Public Class Methods

new(base) click to toggle source
# File lib/riak/crdt/set.rb, line 121
def initialize(base)
  @base = base
  @adds = ::Set.new
  @removes = ::Set.new
end

Public Instance Methods

add(element) click to toggle source
# File lib/riak/crdt/set.rb, line 127
def add(element)
  @adds.add element
end
context?() click to toggle source
# File lib/riak/crdt/set.rb, line 146
def context?
  @base.context?
end
delete(element)
Alias for: remove
empty?() click to toggle source
# File lib/riak/crdt/set.rb, line 142
def empty?
  members.empty?
end
include?(element) click to toggle source
# File lib/riak/crdt/set.rb, line 138
def include?(element)
  members.include? element
end
members() click to toggle source
# File lib/riak/crdt/set.rb, line 154
def members
  (@base + @adds).subtract @removes
end
Also aliased as: value
operations() click to toggle source
# File lib/riak/crdt/set.rb, line 160
def operations
  Operation::Update.new.tap do |op|
    op.type = :set
    op.value = {add: @adds.to_a, remove: @removes.to_a}
  end
end
remove(element) click to toggle source
# File lib/riak/crdt/set.rb, line 131
def remove(element)
  raise CrdtError::SetRemovalWithoutContextError.new unless context?
  @removes.add element
end
Also aliased as: delete
to_a() click to toggle source
# File lib/riak/crdt/set.rb, line 150
def to_a
  members.to_a
end
value()
Alias for: members