Sha256: 3012bbd9630ce521259e8abe553bb6ae2fd999c2aca1210150f7536c552535f5

Contents?: true

Size: 794 Bytes

Versions: 5

Compression:

Stored size: 794 Bytes

Contents

module Grape
  module ContentTypes
    # Content types are listed in order of preference.
    CONTENT_TYPES = ActiveSupport::OrderedHash[
                    :xml,  'application/xml',
                    :serializable_hash, 'application/json',
                    :json, 'application/json',
                    :binary, 'application/octet-stream',
                    :txt,  'text/plain'
   ]

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

      settings.each_with_object(ActiveSupport::OrderedHash.new) { |value, result| result.merge!(value) }
    end

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
grape-0.13.0 lib/grape/util/content_types.rb
grape-0.12.0 lib/grape/util/content_types.rb
grape-0.11.0 lib/grape/util/content_types.rb
grape-0.10.1 lib/grape/util/content_types.rb
grape-0.10.0 lib/grape/util/content_types.rb