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, line 43
def initialize(args = {})
  @parsers = {}
  ALLOWED_PARAMS.each { |param| parsers[param] = args[param] } unless args.nil?
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, line 49
def parse(method = nil, params = nil)
  a_parser = nil
  a_parser = parsers[method.to_sym] unless method.nil? || parsers.nil?
  a_parser&.parse params
end