module AssetRam
Use in views to cache the asset path computation.
For example, in a HAML file:
AssetRam::Helper.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::Helper.cache
(key: site) { stylesheet_link_tag(“themes/#{site}”, media: nil) }¶ ↑
To test and compare if this lib actually improves performance, set the ASSET_RAM_DISABLE env var and it will transparently never cache.
Constants
- VERSION