Class: Reforge::Transformation::Tree::AggregateNode::ArrayNode
- Inherits:
-
Object
- Object
- Reforge::Transformation::Tree::AggregateNode::ArrayNode
- Defined in:
- lib/reforge/transformation/tree/aggregate_node/array_node.rb
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Returns the value of attribute children.
Instance Method Summary collapse
- #call(source) ⇒ Object
-
#initialize ⇒ ArrayNode
constructor
A new instance of ArrayNode.
- #update_path(path) ⇒ Object
Constructor Details
#initialize ⇒ ArrayNode
Returns a new instance of ArrayNode.
10 11 12 |
# File 'lib/reforge/transformation/tree/aggregate_node/array_node.rb', line 10 def initialize @children = [] end |
Instance Attribute Details
#children ⇒ Object (readonly)
Returns the value of attribute children.
8 9 10 |
# File 'lib/reforge/transformation/tree/aggregate_node/array_node.rb', line 8 def children @children end |
Instance Method Details
#call(source) ⇒ Object
14 15 16 17 |
# File 'lib/reforge/transformation/tree/aggregate_node/array_node.rb', line 14 def call(source) # TRICKY: holes can be present, e.g. at key 1 after setting children at keys 0 and 2 children.map { |child| child&.call(source) } end |
#update_path(path) ⇒ Object
19 20 21 22 |
# File 'lib/reforge/transformation/tree/aggregate_node/array_node.rb', line 19 def update_path(path) # TRICKY: holes can be present, e.g. at key 1 after setting children at keys 0 and 2 children.each_with_index { |child, index| child&.update_path(path + [index]) } end |