Module: Grape::Parser::Base

Defined in:
lib/grape/parser/base.rb

Constant Summary collapse

PARSERS =
{
  json: Grape::Parser::Json,
  jsonapi: Grape::Parser::Json,
  xml: Grape::Parser::Xml
}

Class Method Summary collapse

Class Method Details

.parser_for(api_format, options = {}) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/grape/parser/base.rb', line 15

def parser_for(api_format, options = {})
  spec = parsers(options)[api_format]
  case spec
  when nil
    nil
  when Symbol
    method(spec)
  else
    spec
  end
end

.parsers(options) ⇒ Object



11
12
13
# File 'lib/grape/parser/base.rb', line 11

def parsers(options)
  PARSERS.merge(options[:parsers] || {})
end