Class: ViewComponent::CacheDigest::Resolver
- Inherits:
-
ActionView::Resolver
- Object
- ActionView::Resolver
- ViewComponent::CacheDigest::Resolver
- Defined in:
- lib/view_component/cache_digest/resolver.rb
Overview
Synthesizes the templates Rails' ActionView::Digestor digests components from.
Once DependencyTracking reports view_component/cache_digest/foo_component
as a dependency, the Digestor tries to find a template at that path. No such
file exists: a component's rendered output depends on its template and its
Ruby class, its sidecar files, and its superclasses.
This resolver answers with a synthetic template whose source encodes all of
those inputs. The template is never compiled or rendered; the Digestor only
reads #source to hash it and to scan it for further dependencies.
Constant Summary collapse
- SIDECAR_EXTENSIONS =
Extensions whose contents are hashed into the synthetic source.
%w[yml yaml].freeze
Class Method Summary collapse
Instance Method Summary collapse
- #eql?(other) ⇒ Boolean (also: #==)
- #find_templates(name, prefix, partial, details, locals = []) ⇒ Object
- #to_s ⇒ Object (also: #to_path)
Class Method Details
.instance ⇒ Object
22 23 24 |
# File 'lib/view_component/cache_digest/resolver.rb', line 22 def instance INSTANCE end |
Instance Method Details
#eql?(other) ⇒ Boolean Also known as: ==
45 46 47 |
# File 'lib/view_component/cache_digest/resolver.rb', line 45 def eql?(other) self.class.equal?(other.class) end |
#find_templates(name, prefix, partial, details, locals = []) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/view_component/cache_digest/resolver.rb', line 27 def find_templates(name, prefix, partial, details, locals = []) virtual_path = [prefix.presence, name].compact.join("/") component = CacheDigest.component_for(virtual_path) return [] unless component [build_template(component, virtual_path, details)] rescue # Never let digest resolution break rendering. Returning no template # makes the Digestor treat this as a missing node, which degrades to # the behavior components have without this feature. [] end |
#to_s ⇒ Object Also known as: to_path
40 41 42 |
# File 'lib/view_component/cache_digest/resolver.rb', line 40 def to_s "ViewComponent::CacheDigest::Resolver" end |