class Gravaty::Parser

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

Author

Marco Bresciani

rubocop:disable Style/AsciiComments

Copyright

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

rubocop:enable Style/AsciiComments

License

GNU General Public License version 3

Attributes

parsers[R]

Public Class Methods

new(args = {}) click to toggle source
   # File lib/gravaty/parser.rb
43 def initialize(args = {})
44   @parsers = {}
45   ALLOWED_PARAMS.each { |param| parsers[param] = args[param] } unless args.nil?
46 end

Public Instance Methods

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

Provides the duck type for a generic parsing object.

   # File lib/gravaty/parser.rb
49 def parse(method = nil, params = nil)
50   a_parser = nil
51   a_parser = parsers[method.to_sym] unless method.nil? || parsers.nil?
52   a_parser&.parse params
53 end