Class: Sprockets::Helpers::AssetPath
- Defined in:
- lib/sprockets/helpers/asset_path.rb
Overview
‘AssetPath` generates a full path for an asset that exists in Sprockets environment.
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from BasePath
Instance Method Summary collapse
-
#initialize(uri, asset, environment, options = {}) ⇒ AssetPath
constructor
A new instance of AssetPath.
- #to_a ⇒ Object
Methods inherited from BasePath
#sprockets_helpers_settings, #to_s
Constructor Details
#initialize(uri, asset, environment, options = {}) ⇒ AssetPath
Returns a new instance of AssetPath.
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/sprockets/helpers/asset_path.rb', line 6 def initialize(uri, asset, environment, = {}) @uri = uri @asset = asset @environment = environment @options = @options = { :body => false, :digest => sprockets_helpers_settings.digest, :prefix => sprockets_helpers_settings.prefix }.merge @uri.path = @options[:digest] ? asset.digest_path : asset.logical_path end |
Instance Method Details
#to_a ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/sprockets/helpers/asset_path.rb', line 20 def to_a if @asset.respond_to?(:to_a) @asset.to_a.map do |dependency| AssetPath.new(@uri.clone, dependency, @environment, @options.merge(:body => true)).to_s end elsif @asset.[:included] @asset.[:included].map do |uri| AssetPath.new(@uri.clone, @environment.load(uri), @environment, @options.merge(:body => true)).to_s end else AssetPath.new(@uri.clone, @asset, @environment, @options.merge(:body => true)).to_s end end |