Class: AssetHelper
- Inherits:
-
Object
- Object
- AssetHelper
- Defined in:
- lib/asset_helper.rb
Constant Summary collapse
- REDIS_PREFIX =
'ub-b64-asset'
Class Method Summary collapse
Class Method Details
.base64_encoded(path, cache: false) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/asset_helper.rb', line 7 def base64_encoded(path, cache: false) key = "#{REDIS_PREFIX}#{path}" if cache b64_asset = redis.get(key) return b64_asset if b64_asset.present? end b64_asset = encode path redis.set key, b64_asset, ex: 1.day.to_i if cache b64_asset end |
.inlined(path) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/asset_helper.rb', line 20 def inlined(path) if Rails.env.development? || Rails.env.test? asset = Rails.application.assets.find_asset(path) else filesystem_path = Rails.application.assets_manifest.assets[path] asset = File.read(Rails.root.join('public', 'assets', filesystem_path)) end asset end |