Class: Grape::ContentTypes::LookupCache

Inherits:
Util::Cache show all
Defined in:
lib/grape/content_types.rb

Instance Attribute Summary

Attributes inherited from Util::Cache

#cache

Instance Method Summary collapse

Methods inherited from Util::Cache

#[]

Constructor Details

#initializeLookupCache

Returns a new instance of LookupCache.



75
76
77
78
79
80
81
82
83
# File 'lib/grape/content_types.rb', line 75

def initialize
  super
  @cache = Hash.new do |h, from_settings|
    h[from_settings.dup.freeze] = from_settings.each_with_object({}) do |(format, media_type), lookup|
      lookup[format] = media_type
      lookup[format.is_a?(String) ? format.to_sym : format.to_s] = media_type
    end.freeze
  end
end