Class: Oplogjam::Operators::Unset
- Inherits:
-
Object
- Object
- Oplogjam::Operators::Unset
- Defined in:
- lib/oplogjam/operators/unset.rb
Instance Attribute Summary collapse
-
#unsets ⇒ Object
readonly
Returns the value of attribute unsets.
Class Method Summary collapse
Instance Method Summary collapse
- #delete(column) ⇒ Object
-
#initialize(unsets = []) ⇒ Unset
constructor
A new instance of Unset.
- #unset_field(path) ⇒ Object
- #unset_index(path) ⇒ Object
Constructor Details
#initialize(unsets = []) ⇒ Unset
Returns a new instance of Unset.
21 22 23 |
# File 'lib/oplogjam/operators/unset.rb', line 21 def initialize(unsets = []) @unsets = unsets end |
Instance Attribute Details
#unsets ⇒ Object (readonly)
Returns the value of attribute unsets.
19 20 21 |
# File 'lib/oplogjam/operators/unset.rb', line 19 def unsets @unsets end |
Class Method Details
.from(operation) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/oplogjam/operators/unset.rb', line 7 def self.from(operation) operation.each_with_object(new) do |(dotted_path, _), unset| path = dotted_path.split(FIELD_SEPARATOR) if path.last =~ NUMERIC_INDEX unset.unset_index(path) else unset.unset_field(path) end end end |
Instance Method Details
#delete(column) ⇒ Object
33 34 35 36 37 |
# File 'lib/oplogjam/operators/unset.rb', line 33 def delete(column) unsets.inject(column) do |subject, unset| unset.delete(subject) end end |
#unset_field(path) ⇒ Object
25 26 27 |
# File 'lib/oplogjam/operators/unset.rb', line 25 def unset_field(path) unsets << UnsetField.new(path) end |
#unset_index(path) ⇒ Object
29 30 31 |
# File 'lib/oplogjam/operators/unset.rb', line 29 def unset_index(path) unsets << UnsetIndex.new(path) end |