Module: Grape::ErrorFormatter
- Extended by:
- ActiveSupport::Autoload, Util::Registrable
- Defined in:
- lib/grape.rb,
lib/grape/error_formatter.rb,
lib/grape/error_formatter/txt.rb,
lib/grape/error_formatter/xml.rb,
lib/grape/error_formatter/base.rb,
lib/grape/error_formatter/json.rb
Defined Under Namespace
Modules: Base, Json, Txt, Xml
Class Method Summary
collapse
default_elements, register
Class Method Details
6
7
8
9
10
11
12
13
14
|
# File 'lib/grape/error_formatter.rb', line 6
def builtin_formatters
@builtin_formatters ||= {
serializable_hash: Grape::ErrorFormatter::Json,
json: Grape::ErrorFormatter::Json,
jsonapi: Grape::ErrorFormatter::Json,
txt: Grape::ErrorFormatter::Txt,
xml: Grape::ErrorFormatter::Xml
}
end
|
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/grape/error_formatter.rb', line 20
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
|
16
17
18
|
# File 'lib/grape/error_formatter.rb', line 16
def formatters(options)
builtin_formatters.merge(default_elements).merge(options[:error_formatters] || {})
end
|