Sha256: 85ab8635fb1440e3efc712120aea5d7b362a26a0e7cdfef1b3e44cbb32cf6971
Contents?: true
Size: 788 Bytes
Versions: 3
Compression:
Stored size: 788 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
grape-0.17.0 | lib/grape/formatter.rb |
grape-0.16.2 | lib/grape/formatter.rb |
grape-0.16.1 | lib/grape/formatter.rb |