Sha256: f55657b3cb73e9fb1959d5113989817974b736a4773017a7c798e629806d8ef4
Contents?: true
Size: 787 Bytes
Versions: 14
Compression:
Stored size: 787 Bytes
Contents
module Grape module Formatter extend Util::Registrable class << self def builtin_formmaters @builtin_formatters ||= { json: Grape::Formatter::Json, jsonapi: Grape::Formatter::Json, serializable_hash: Grape::Formatter::SerializableHash, txt: Grape::Formatter::Txt, xml: Grape::Formatter::Xml } end def formatters(options) builtin_formmaters.merge(default_elements).merge(options[:formatters] || {}) end 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 end end end
Version data entries
14 entries across 14 versions & 1 rubygems