module Decanter::Parser::Core::ClassMethods
Public Instance Methods
Source
# File lib/decanter/parser/core.rb, line 11 def _parse(name, value, options={}) { name => @parser.call(value, options) } end
Source
# File lib/decanter/parser/core.rb, line 30 def allow(*args) @allowed = args end
Set allowed classes
Source
# File lib/decanter/parser/core.rb, line 45 def allowed?(value) @allowed && @allowed.any? { |allowed| value.is_a? allowed } end
Check for allowed classes
Source
# File lib/decanter/parser/core.rb, line 16 def parse(name, value, options={}) if allowed?(value) { name => value } else _parse(name, value, options) end end
Check if allowed, parse if not
Source
# File lib/decanter/parser/core.rb, line 25 def parser(&block) @parser = block end
Define parser
Source
# File lib/decanter/parser/core.rb, line 35 def pre(*parsers) @pre = parsers end
Set preparsers
Source
# File lib/decanter/parser/core.rb, line 40 def preparsers @pre || [] end
Get prepareer