Class: Reforge::Transformation::Tree

Inherits:
Object
  • Object
show all
Defined in:
lib/reforge/transformation/tree.rb,
lib/reforge/transformation/tree/aggregate_node.rb,
lib/reforge/transformation/tree/transform_node.rb,
lib/reforge/transformation/tree/aggregate_node/factories.rb,
lib/reforge/transformation/tree/aggregate_node/hash_node.rb,
lib/reforge/transformation/tree/aggregate_node/array_node.rb

Defined Under Namespace

Classes: AggregateNode, NodeRedefinitionError, PathPartError, TransformNode

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#rootObject (readonly)

Returns the value of attribute root.



10
11
12
# File 'lib/reforge/transformation/tree.rb', line 10

def root
  @root
end

Instance Method Details

#attach_transform(*path) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/reforge/transformation/tree.rb', line 12

def attach_transform(*path)
  validate_path!(*path)

  # TRICKY: A single-step path means we are wrapping a single transform. We set the root node accordingly,
  # allowing it to fail loudly if it is being redefined
  #
  # A multi-step path means we are wrapping a branching tree with transforms at its leaf nodes. We only
  # initialize the root node if we have not done so already, and then begin attaching the nodes necessitated by
  # the supplied path. The nodes are expected to fail loudly if their attachment rules are violated
  if path.size == 1
    initialize_root(path[0])
  else
    initialize_root(path[0]) if root.nil?
    attach_nodes(*path)
  end

  nil
end

#call(source) ⇒ Object



31
32
33
# File 'lib/reforge/transformation/tree.rb', line 31

def call(source)
  root.call(source)
end