class ActionView::LookupContext

:nodoc:
only once during the request, it speeds up all cache accesses.
view paths, used in the resolver cache lookup. Since this key is generated
LookupContext is also responsible for generating a key, given to
required for looking up templates, i.e. view paths and details.
LookupContext is the object responsible for holding all information
= Action View Lookup Context

def self.register_detail(name, &block)

def self.register_detail(name, &block)
  self.registered_details << name
  initialize = registered_details.map { |n| "@details[:#{n}] = details[:#{n}] || default_#{n}" }
  Accessors.send :define_method, :"default_#{name}", &block
  Accessors.module_eval <<-METHOD, __FILE__, __LINE__ + 1
    def #{name}
      @details.fetch(:#{name}, [])
    end
    def #{name}=(value)
      value = value.present? ? Array(value) : default_#{name}
      _set_detail(:#{name}, value) if value != @details[:#{name}]
    end
    remove_possible_method :initialize_details
    def initialize_details(details)
      #{initialize.join("\n")}
    end
  METHOD
end

def formats=(values)

add :html as fallback to :js.
Override formats= to expand ["*/*"] values and automatically
def formats=(values)
  if values
    values.concat(default_formats) if values.delete "*/*".freeze
    if values == [:js]
      values << :html
      @html_fallback_for_js = true
    end
  end
  super(values)
end

def initialize(view_paths, details = {}, prefixes = [])

def initialize(view_paths, details = {}, prefixes = [])
  @details, @details_key = {}, nil
  @cache = true
  @prefixes = prefixes
  @rendered_format = nil
  self.view_paths = view_paths
  initialize_details(details)
end

def locale

Override locale to return a symbol instead of array.
def locale
  @details[:locale].first
end

def locale=(value)

acting as proxy, which we need to skip.
to original_config, it means that it has a copy of the original I18n configuration and it's
Overload locale= to also set the I18n.locale. If the current I18n.config object responds
def locale=(value)
  if value
    config = I18n.config.respond_to?(:original_config) ? I18n.config.original_config : I18n.config
    config.locale = value
  end
  super(default_locale)
end