class Gravaty::Parser

This class is a simple utility that is used to parse and filter parameters for gravaty.

Author

Marco Bresciani

Copyright

Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Marco Bresciani

License

GNU General Public License version 3

Attributes

parsers[R]

Public Class Methods

new(args = {}) click to toggle source
   # File lib/gravaty/parser.rb
34 def initialize(args = {})
35   @parsers = Hash.new
36   ALLOWED_PARAMS.each do |param|
37     parsers[param] = args[param]
38   end unless args.nil?
39 end

Public Instance Methods

parse(method = nil, value = nil) click to toggle source

Provides the duck type for a generic parsing object.

   # File lib/gravaty/parser.rb
42 def parse(method = nil, value = nil)
43   a_parser = nil
44   a_parser = parsers[method.to_sym] unless method.nil? or
45       parsers.nil?
46   a_parser.parse value unless a_parser.nil?
47 end