Module: Decanter::Parser::Core::ClassMethods
- Defined in:
- lib/decanter/parser/core.rb
Instance Method Summary collapse
-
#allow(*args) ⇒ Object
Set allowed classes.
-
#allowed?(value) ⇒ Boolean
Check for allowed classes.
-
#parse(name, value, options = {}) ⇒ Object
Check if allowed, parse if not.
-
#parser(&block) ⇒ Object
Define parser.
-
#pre(*parsers) ⇒ Object
Set preparsers.
-
#preparsers ⇒ Object
Get prepareer.
Instance Method Details
#allow(*args) ⇒ Object
Set allowed classes
26 27 28 |
# File 'lib/decanter/parser/core.rb', line 26 def allow(*args) @allowed = args end |
#allowed?(value) ⇒ Boolean
Check for allowed classes
41 42 43 |
# File 'lib/decanter/parser/core.rb', line 41 def allowed?(value) @allowed && @allowed.any? { |allowed| value.is_a? allowed } end |
#parse(name, value, options = {}) ⇒ Object
Check if allowed, parse if not
12 13 14 15 16 17 18 |
# File 'lib/decanter/parser/core.rb', line 12 def parse(name, value, ={}) if allowed?(value) { name => value } else _parse(name, value, ) end end |
#parser(&block) ⇒ Object
Define parser
21 22 23 |
# File 'lib/decanter/parser/core.rb', line 21 def parser(&block) @parser = block end |
#pre(*parsers) ⇒ Object
Set preparsers
31 32 33 |
# File 'lib/decanter/parser/core.rb', line 31 def pre(*parsers) @pre = parsers end |
#preparsers ⇒ Object
Get prepareer
36 37 38 |
# File 'lib/decanter/parser/core.rb', line 36 def preparsers @pre || [] end |