Class: Babl::Operators::With::WithNode
- Inherits:
-
Object
- Object
- Babl::Operators::With::WithNode
- Defined in:
- lib/babl/operators/with.rb
Instance Method Summary collapse
- #dependencies ⇒ Object
- #documentation ⇒ Object
-
#initialize(node, nodes, block) ⇒ WithNode
constructor
A new instance of WithNode.
- #pinned_dependencies ⇒ Object
- #render(ctx) ⇒ Object
Constructor Details
#initialize(node, nodes, block) ⇒ WithNode
Returns a new instance of WithNode.
19 20 21 22 23 |
# File 'lib/babl/operators/with.rb', line 19 def initialize(node, nodes, block) @node = node @nodes = nodes @block = block end |
Instance Method Details
#dependencies ⇒ Object
29 30 31 32 |
# File 'lib/babl/operators/with.rb', line 29 def dependencies # Dependencies of 'node' are explicitely ignored nodes.map(&:dependencies).reduce({}) { |a, b| Babl::Utils::Hash.deep_merge(a, b) } end |
#documentation ⇒ Object
25 26 27 |
# File 'lib/babl/operators/with.rb', line 25 def documentation node.documentation end |
#pinned_dependencies ⇒ Object
34 35 36 |
# File 'lib/babl/operators/with.rb', line 34 def pinned_dependencies (nodes + [node]).map(&:pinned_dependencies).reduce({}) { |a, b| Babl::Utils::Hash.deep_merge(a, b) } end |
#render(ctx) ⇒ Object
38 39 40 41 42 43 |
# File 'lib/babl/operators/with.rb', line 38 def render(ctx) values = nodes.map { |n| n.render(ctx) } node.render(ctx.move_forward_block(:__block__) do block.arity.zero? ? ctx.object.instance_exec(&block) : block.call(*values) end) end |