Methods
#
D
F
L
S
U
W
Attributes
[RW] cache
Instance Public methods
disable_cache()

Temporary skip passing the details_key forward.

# File actionpack/lib/action_view/lookup_context.rb, line 154
def disable_cache
  old_value, @cache = @cache, false
  yield
ensure
  @cache = old_value
end
formats=(values)

Overload formats= to expand [“/”] values and automatically add :html as fallback to :js.

# File actionpack/lib/action_view/lookup_context.rb, line 172
def formats=(values)
  if values
    values.concat(_formats_defaults) if values.delete "*/*"
    values << :html if values == [:js]
  end
  super(values)
end
locale()

Overload locale to return a symbol instead of array.

# File actionpack/lib/action_view/lookup_context.rb, line 187
def locale
  @details[:locale].first
end
locale=(value)

Overload locale= to also set the I18n.locale. If the current I18n.config object responds to original_config, it means that it’s has a copy of the original I18n configuration and it’s acting as proxy, which we need to skip.

# File actionpack/lib/action_view/lookup_context.rb, line 194
def locale=(value)
  if value
    config = I18n.config.respond_to?(:original_config) ? I18n.config.original_config : I18n.config
    config.locale = value
  end

  super(@skip_default_locale ? I18n.locale : _locale_defaults)
end
skip_default_locale!()

Do not use the default locale on template lookup.

# File actionpack/lib/action_view/lookup_context.rb, line 181
def skip_default_locale!
  @skip_default_locale = true
  self.locale = nil
end
update_details(new_details)

Update the details keys by merging the given hash into the current details hash. If a block is given, the details are modified just during the execution of the block and reverted to the previous value after.

# File actionpack/lib/action_view/lookup_context.rb, line 223
def update_details(new_details)
  old_details = @details.dup

  registered_detail_setters.each do |key, setter|
    send(setter, new_details[key]) if new_details.key?(key)
  end

  begin
    yield
  ensure
    @details_key = nil
    @details = old_details
  end
end
with_layout_format()

A method which only uses the first format in the formats array for layout lookup. This method plays straight with instance variables for performance reasons.

# File actionpack/lib/action_view/lookup_context.rb, line 205
def with_layout_format
  if formats.size == 1
    yield
  else
    old_formats = formats
    _set_detail(:formats, formats[0,1])

    begin
      yield
    ensure
      _set_detail(:formats, old_formats)
    end
  end
end
Instance Protected methods
_set_detail(key, value)
# File actionpack/lib/action_view/lookup_context.rb, line 240
def _set_detail(key, value)
  @details_key = nil
  @details = @details.dup if @details.frozen?
  @details[key] = value.freeze
end