class ActionView::LookupContext

Experimental RBS support (using type sampling data from the type_fusion project).

# sig/action_view/lookup_context.rbs

class ActionView::LookupContext
  def self.register_detail: (Symbol name, ) -> Symbol
  def formats=: (Array[Symbol] value, Array[Symbol] values) -> Array[Symbol]
  def initialize: (ActionView::PathSet view_paths, ?Hash details, ?Array[String] prefixes) -> void
  def initialize_details: (Hash target, Hash details) -> Hash
end

: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)

Experimental RBS support (using type sampling data from the type_fusion project).

def self.register_detail: (Symbol name, ) -> Symbol

This signature was generated using 4 samples from 1 application.

def self.register_detail(name, &block)
  registered_details << name
  Accessors::DEFAULT_PROCS[name] = block
  Accessors.define_method(:"default_#{name}", &block)
  Accessors.module_eval <<-METHOD, __FILE__, __LINE__ + 1
    def #{name}
      @details[:#{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
  @digest_cache ||= DetailsKey.digest_cache(@details)
end

def formats=(values)

Experimental RBS support (using type sampling data from the type_fusion project).

def formats=: (Symbol value,  values) -> Symbol

This signature was generated using 4 samples from 1 application.

add :html as fallback to :js.
Override formats= to expand ["*/*"] values and automatically
def formats=(values)
  if values
    values = values.dup
    values.concat(default_formats) if values.delete "*/*"
    values.uniq!
    invalid_values = (values - Template::Types.symbols)
    unless invalid_values.empty?
      raise ArgumentError, "Invalid formats: #{invalid_values.map(&:inspect).join(", ")}"
    end
    if values == [:js]
      values << :html
      @html_fallback_for_js = true
    end
  end
  super(values)
end

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

Experimental RBS support (using type sampling data from the type_fusion project).

def initialize: (ActionView::PathSet view_paths, ? details, ? prefixes) -> void

This signature was generated using 1 sample from 1 application.

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

def initialize_details(target, details)

Experimental RBS support (using type sampling data from the type_fusion project).

def initialize_details: (locale |  | formats | Symbol | Symbol | Symbol | Symbol | Symbol | Symbol | Symbol | Symbol | Symbol | Symbol | Symbol | Symbol | Symbol | Symbol | Symbol | Symbol | Symbol | Symbol | Symbol | Symbol | Symbol | Symbol | Symbol | Symbol | Symbol | Symbol | Symbol | Symbol | Symbol | Symbol | Symbol | Symbol | Symbol | Symbol | variants |  | handlers | Symbol | Symbol | Symbol | Symbol | Symbol target,  details) -> locale |  | formats | Symbol | Symbol | Symbol | Symbol | Symbol | Symbol | Symbol | Symbol | Symbol | Symbol | Symbol | Symbol | Symbol | Symbol | Symbol | Symbol | Symbol | Symbol | Symbol | Symbol | Symbol | Symbol | Symbol | Symbol | Symbol | Symbol | Symbol | Symbol | Symbol | Symbol | Symbol | Symbol | Symbol | Symbol | variants |  | handlers | Symbol | Symbol | Symbol | Symbol | Symbol

This signature was generated using 2 samples from 1 application.

def initialize_details(target, details)
  LookupContext.registered_details.each do |k|
    target[k] = details[k] || Accessors::DEFAULT_PROCS[k].call
  end
  target
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

def with_prepended_formats(formats)

def with_prepended_formats(formats)
  details = @details.dup
  details[:formats] = formats
  self.class.new(@view_paths, details, @prefixes)
end