Class: ActionView::Digestor
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Subclasses:
ActionView::PartialDigestor
|
|
Inherits: | Object |
Defined in: | actionview/lib/action_view/digestor.rb |
Class Attribute Summary
- .cache (also: #cache) readonly
Class Method Summary
-
.digest(options)
Supported options:
- .new(options) ⇒ Digestor constructor
Instance Attribute Summary
Instance Method Summary
Constructor Details
.new(options) ⇒ Digestor
Class Attribute Details
.cache (readonly) Also known as: #cache
[ GitHub ]# File 'actionview/lib/action_view/digestor.rb', line 7
cattr_reader(:cache)
Class Method Details
.digest(options)
Supported options:
-
#finder - An instance of LookupContext
-
#dependencies - An array of dependent views
-
partial
- Specifies whether the template is a partial
# File 'actionview/lib/action_view/digestor.rb', line 18
def digest( ) .assert_valid_keys(:name, :finder, :dependencies, :partial) cache_key = ([ [:name], [:finder].details_key.hash ].compact + Array.wrap( [:dependencies])).join('.') # this is a correctly done double-checked locking idiom # (ThreadSafe::Cache's lookups have volatile semantics) @@cache[cache_key] || @@digest_monitor.synchronize do @@cache.fetch(cache_key) do # re-check under lock compute_and_store_digest(cache_key, ) end end end
Instance Attribute Details
#cache (readonly)
[ GitHub ]# File 'actionview/lib/action_view/digestor.rb', line 7
cattr_reader(:cache)
#finder (readonly)
[ GitHub ]# File 'actionview/lib/action_view/digestor.rb', line 54
attr_reader :name, :finder, :
#name (readonly)
[ GitHub ]# File 'actionview/lib/action_view/digestor.rb', line 54
attr_reader :name, :finder, :
#options (readonly)
[ GitHub ]Instance Method Details
#dependencies
[ GitHub ]# File 'actionview/lib/action_view/digestor.rb', line 70
def dependencies DependencyTracker.find_dependencies(name, template) rescue ActionView::MissingTemplate logger.try :error, " '#{name}' file doesn't exist, so no dependencies" [] end
#digest
[ GitHub ]# File 'actionview/lib/action_view/digestor.rb', line 61
def digest Digest::MD5.hexdigest("#{source}-#{dependency_digest}").tap do |digest| logger.try :debug, " Cache digest for #{template.inspect}: #{digest}" end rescue ActionView::MissingTemplate logger.try :error, " Couldn't find template for digesting: #{name}" '' end
#nested_dependencies
[ GitHub ]# File 'actionview/lib/action_view/digestor.rb', line 77
def nested_dependencies dependencies.collect do |dependency| dependencies = PartialDigestor.new(name: dependency, finder: finder).nested_dependencies dependencies.any? ? { dependency => dependencies } : dependency end end