Module: Grape::ErrorFormatter::Base

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

Constant Summary

FORMATTERS =
{
  :serializable_hash => Grape::ErrorFormatter::Json,
  :json => Grape::ErrorFormatter::Json,
  :txt => Grape::ErrorFormatter::Txt,
  :xml => Grape::ErrorFormatter::Xml
}

Class Method Summary (collapse)

Class Method Details

+ (Object) formatter_for(api_format, options = {})



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/grape/error_formatter/base.rb', line 18

def formatter_for(api_format, options = {})
  spec = formatters(options)[api_format]
  case spec
  when nil
    options[:default_error_formatter] || Grape::ErrorFormatter::Txt
  when Symbol
    method(spec)
  else
    spec
  end
end

+ (Object) formatters(options)



14
15
16
# File 'lib/grape/error_formatter/base.rb', line 14

def formatters(options)
  FORMATTERS.merge(options[:error_formatters] || {})
end