Class: Oplogjam::Operators::Intermediate
- Inherits:
-
Object
- Object
- Oplogjam::Operators::Intermediate
show all
- Defined in:
- lib/oplogjam/operators/intermediate.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(path, tree = {}) ⇒ Intermediate
Returns a new instance of Intermediate.
6
7
8
9
|
# File 'lib/oplogjam/operators/intermediate.rb', line 6
def initialize(path, tree = {})
@path = path
@tree = tree
end
|
Instance Attribute Details
#path ⇒ Object
Returns the value of attribute path.
4
5
6
|
# File 'lib/oplogjam/operators/intermediate.rb', line 4
def path
@path
end
|
#tree ⇒ Object
Returns the value of attribute tree.
4
5
6
|
# File 'lib/oplogjam/operators/intermediate.rb', line 4
def tree
@tree
end
|
Instance Method Details
#nodes ⇒ Object
42
43
44
|
# File 'lib/oplogjam/operators/intermediate.rb', line 42
def nodes
tree.values
end
|
#populate(path) ⇒ Object
11
12
13
14
15
16
17
|
# File 'lib/oplogjam/operators/intermediate.rb', line 11
def populate(path)
if path.last =~ NUMERIC_INDEX
populate_index(path)
else
populate_field(path)
end
end
|
#populate_field(path) ⇒ Object
27
28
29
|
# File 'lib/oplogjam/operators/intermediate.rb', line 27
def populate_field(path)
tree[path] ||= IntermediateField.new(path)
end
|
#populate_index(path) ⇒ Object
31
32
33
|
# File 'lib/oplogjam/operators/intermediate.rb', line 31
def populate_index(path)
tree[path] ||= IntermediateIndex.new(path)
end
|
#set(path, value) ⇒ Object
19
20
21
22
23
24
25
|
# File 'lib/oplogjam/operators/intermediate.rb', line 19
def set(path, value)
if path.last =~ NUMERIC_INDEX
set_index(path, value)
else
set_field(path, value)
end
end
|
#set_field(path, value) ⇒ Object
34
35
36
|
# File 'lib/oplogjam/operators/intermediate.rb', line 34
def set_field(path, value)
tree[path] = FieldAssignment.new(path, value)
end
|
#set_index(path, value) ⇒ Object
38
39
40
|
# File 'lib/oplogjam/operators/intermediate.rb', line 38
def set_index(path, value)
tree[path] = IndexAssignment.new(path, value)
end
|