Module: Grape::ContentTypes

Defined in:
lib/grape/util/content_types.rb

Constant Summary collapse

CONTENT_TYPES =

Content types are listed in order of preference.

{ # rubocop:disable Style/MutableConstant
  xml: 'application/xml',
  serializable_hash: 'application/json',
  json: 'application/json',
  binary: 'application/octet-stream',
  txt: 'text/plain'
}

Class Method Summary collapse

Class Method Details

.content_types_for(from_settings) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/grape/util/content_types.rb', line 20

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

.content_types_for_settings(settings) ⇒ Object



14
15
16
17
18
# File 'lib/grape/util/content_types.rb', line 14

def self.content_types_for_settings(settings)
  return if settings.blank?

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