Class: CallableTree::Node::Internal::Strategy::Compose

Inherits:
Object
  • Object
show all
Includes:
CallableTree::Node::Internal::Strategy
Defined in:
lib/callable_tree/node/internal/strategy/compose.rb

Instance Method Summary collapse

Methods included from CallableTree::Node::Internal::Strategy

#==, #eql?, #hash, #name

Instance Method Details

#call(nodes, *inputs, **options) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/callable_tree/node/internal/strategy/compose.rb', line 10

def call(nodes, *inputs, **options)
  head, *tail = inputs
  nodes.reduce(head) do |input, node|
    inputs = [input, *tail]
    if node.match?(*inputs, **options)
      node.call(*inputs, **options)
    else
      input
    end
  end
end