Class: Riak::Crdt::Set::BatchSet
Instance Method Summary collapse
- #add(element) ⇒ Object
- #context? ⇒ Boolean
- #empty? ⇒ Boolean
- #include?(element) ⇒ Boolean
-
#initialize(base) ⇒ BatchSet
constructor
A new instance of BatchSet.
- #members ⇒ Object (also: #value)
- #operations ⇒ Object
- #remove(element) ⇒ Object (also: #delete)
- #to_a ⇒ Object
Constructor Details
Instance Method Details
#add(element) ⇒ Object
127 128 129 |
# File 'lib/riak/crdt/set.rb', line 127 def add(element) @adds.add element end |
#context? ⇒ Boolean
146 147 148 |
# File 'lib/riak/crdt/set.rb', line 146 def context? @base.context? end |
#empty? ⇒ Boolean
142 143 144 |
# File 'lib/riak/crdt/set.rb', line 142 def empty? members.empty? end |
#include?(element) ⇒ Boolean
138 139 140 |
# File 'lib/riak/crdt/set.rb', line 138 def include?(element) members.include? element end |
#members ⇒ Object Also known as: value
154 155 156 |
# File 'lib/riak/crdt/set.rb', line 154 def members (@base + @adds).subtract @removes end |
#operations ⇒ Object
160 161 162 163 164 165 |
# 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) ⇒ Object Also known as: delete
131 132 133 134 |
# File 'lib/riak/crdt/set.rb', line 131 def remove(element) raise CrdtError::SetRemovalWithoutContextError.new unless context? @removes.add element end |
#to_a ⇒ Object
150 151 152 |
# File 'lib/riak/crdt/set.rb', line 150 def to_a members.to_a end |