Module: AssetRam
- Defined in:
- lib/asset_ram.rb,
lib/asset_ram/version.rb
Overview
Use in views to cache the asset path computation.
Preferred usage (since v1.1.0):
= AssetRam.cache { favicon_link_tag('favicon/favicon.ico', rel: 'icon') }
The calculated asset paths are keyed by source file name and line number. The results are stored in RAM.
Sometimes, a key is needed if the code is run in different contexts, like a multi-tenant site:
= AssetRam.cache(key: site) { stylesheet_link_tag("themes/#{site}", media: nil) }
For compatibility, you can still use:
= AssetRam::Helper.cache { ... }
To test and compare if this lib actually improves performance, set the ASSET_RAM_DISABLE env var and it will transparently never cache.
Defined Under Namespace
Constant Summary collapse
- VERSION =
"1.1.0"
Class Method Summary collapse
-
.cache(key: '', &blk) ⇒ Object
The simpler API: AssetRam.cache { … }.