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 generatedLookupContext
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 Accessors::DEFAULT_PROCS[name] = block 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 METHOD end
def digest_cache
def digest_cache details_key.digest_cache end
def formats=(values)
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_key = nil @cache = true @prefixes = prefixes @rendered_format = nil @details = initialize_details({}, details) self.view_paths = view_paths end
def initialize_details(target, details)
def initialize_details(target, details) registered_details.each do |k| target[k] = details[k] || Accessors::DEFAULT_PROCS[k].call end target end
def locale
def locale @details[:locale].first end
def locale=(value)
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