Module: Leftovers::ProcessorBuilders::Keyword

Defined in:
lib/leftovers/processor_builders/keyword.rb

Class Method Summary collapse

Class Method Details

.build(value, then_processor) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/leftovers/processor_builders/keyword.rb', line 6

def self.build(value, then_processor)
  return unless value

  then_processor = case value
  when true, '**' then then_processor
  when ::String, ::Hash, ::Array
    Processors::MatchCurrentNode.new(
      MatcherBuilders::NodeName.build(value), then_processor
    )
  # :nocov:
  else raise UnexpectedCase, "Unhandled value #{value.inspect}"
    # :nocov:
  end

  Processors::EachKeyword.new(then_processor)
end