module Grape::Formatter
Public Class Methods
builtin_formmaters()
click to toggle source
# File lib/grape/formatter.rb, line 4 def builtin_formmaters { json: Grape::Formatter::Json, jsonapi: Grape::Formatter::Json, serializable_hash: Grape::Formatter::SerializableHash, txt: Grape::Formatter::Txt, xml: Grape::Formatter::Xml } end
formatter_for(api_format, options = {})
click to toggle source
# File lib/grape/formatter.rb, line 18 def formatter_for(api_format, options = {}) spec = formatters(options)[api_format] case spec when nil ->(obj, _env) { obj } when Symbol method(spec) else spec end end
formatters(options)
click to toggle source
# File lib/grape/formatter.rb, line 14 def formatters(options) builtin_formmaters.merge(options[:formatters] || {}) end