Class: Decanter::Parser::ComposeParser
- Defined in:
- lib/decanter/parser/compose_parser.rb
Class Method Summary collapse
Methods included from Core
Class Method Details
._parse(name, value, options = {}) ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/decanter/parser/compose_parser.rb', line 9 def self._parse(name, value, ={}) raise Decanter::ParseError.new('Must have parsers') unless @parsers # Call each parser on the result of the previous one. initial_result = { name => value } @parsers.reduce(initial_result) do |result, parser| result.keys.reduce({}) do |acc, key| acc.merge(parser.parse(key, result[key], )) end end end |
.parsers(parsers) ⇒ Object
20 21 22 |
# File 'lib/decanter/parser/compose_parser.rb', line 20 def self.parsers(parsers) @parsers = parsers end |