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


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

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


12
13
14
15
16
# File 'lib/grape/util/content_types.rb', line 12

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

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