Module: Grape::ContentTypes

Extended by:
Util::Registrable
Defined in:
lib/grape/content_types.rb

Constant Summary collapse

CONTENT_TYPES =

Content types are listed in order of preference.

{
  xml: 'application/xml',
  serializable_hash: 'application/json',
  json: 'application/json',
  binary: 'application/octet-stream',
  txt: 'text/plain'
}.freeze

Class Method Summary collapse

Methods included from Util::Registrable

default_elements, register

Class Method Details

.content_types_for(from_settings) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/grape/content_types.rb', line 25

def content_types_for(from_settings)
  if from_settings.present?
    from_settings
  else
    Grape::ContentTypes::CONTENT_TYPES.merge(default_elements)
  end
end

.content_types_for_settings(settings) ⇒ Object



19
20
21
22
23
# File 'lib/grape/content_types.rb', line 19

def content_types_for_settings(settings)
  return if settings.blank?

  settings.each_with_object({}) { |value, result| result.merge!(value) }
end