class Decanter::Parser::ComposeParser

Public Class Methods

_parse(name, value, options={}) click to toggle source
# File lib/decanter/parser/compose_parser.rb, line 9
def self._parse(name, value, options={})
  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], options)) 
    end
  end
end
parsers(parsers) click to toggle source
# File lib/decanter/parser/compose_parser.rb, line 20
def self.parsers(parsers)
  @parsers = parsers
end