Sha256: f52f30795fa385338e971314f8417b5a574973a014cdd0d5bc64ebad02623c42

Contents?: true

Size: 634 Bytes

Versions: 3

Compression:

Stored size: 634 Bytes

Contents

module Grape
  module Parser
    extend Util::Registrable

    class << self
      def builtin_parsers
        @builtin_parsers ||= {
          json: Grape::Parser::Json,
          jsonapi: Grape::Parser::Json,
          xml: Grape::Parser::Xml
        }
      end

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

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
grape-0.17.0 lib/grape/parser.rb
grape-0.16.2 lib/grape/parser.rb
grape-0.16.1 lib/grape/parser.rb