Class: Assets::Environment::Cache
- Inherits:
-
Assets::Environment
- Object
- Assets::Environment
- Assets::Environment::Cache
- Includes:
- Adamantium::Flat
- Defined in:
- lib/assets/environment/cache.rb
Overview
Environment that caches assets
Instance Attribute Summary collapse
-
#environment ⇒ Environment
readonly
private
Return inner environment.
Class Method Summary collapse
-
.build(rules) ⇒ Cache
private
Build cache environemnt.
Instance Method Summary collapse
-
#get(name) ⇒ Asset?
Return asset.
-
#initialize(environment) ⇒ undefined
constructor
private
Initialize object.
-
#rule(name) ⇒ Rule?
private
Return rule.
Constructor Details
#initialize(environment) ⇒ undefined
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initialize object
35 36 37 |
# File 'lib/assets/environment/cache.rb', line 35 def initialize(environment) @environment, @cache = environment, {} end |
Instance Attribute Details
#environment ⇒ Environment (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return inner environment
13 14 15 |
# File 'lib/assets/environment/cache.rb', line 13 def environment @environment end |
Class Method Details
Instance Method Details
#get(name) ⇒ Asset?
Return asset
65 66 67 68 69 70 71 72 73 74 |
# File 'lib/assets/environment/cache.rb', line 65 def get(name) rule = rule(name) return unless rule asset = @cache.fetch(name) do return miss(rule) end hit(rule, asset) end |
#rule(name) ⇒ Rule?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return rule
51 52 53 |
# File 'lib/assets/environment/cache.rb', line 51 def rule(name) environment.rule(name) end |