This operation is for performing $bit atomic operations against the database.
Execute the bitwise operation. This correlates to a $bit in MongoDB.
@example Execute the op.
bit.persist
@return [ Integer ] The new value.
@since 2.1.0
# File lib/mongoid/persistence/atomic/bit.rb, line 18 def persist prepare do current = document[field] return nil unless current document[field] = value.inject(current) do |result, (bit, val)| result = result & val if bit.to_s == "and" result = result | val if bit.to_s == "or" result end document[field].tap do collection.update(document.atomic_selector, operation("$bit"), options) document.remove_change(field) end end end
Generated with the Darkfish Rdoc Generator 2.