Class: Sprockets::Helpers::AssetPath

Inherits:
BasePath
  • Object
show all
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

ManifestPath

Instance Attribute Summary

Attributes inherited from BasePath

#options, #uri

Instance Method Summary collapse

Methods inherited from BasePath

#to_s

Constructor Details

#initialize(uri, asset, options = {}) ⇒ AssetPath

Returns a new instance of AssetPath


6
7
8
9
10
11
12
13
14
15
16
# File 'lib/sprockets/helpers/asset_path.rb', line 6

def initialize(uri, asset, options = {})
  @uri = uri
  @asset = asset
  @options = {
    :body => false,
    :digest => Helpers.digest,
    :prefix => Helpers.prefix
  }.merge options

  @uri.path = @options[:digest] ? asset.digest_path : asset.logical_path
end

Instance Method Details

#to_aObject


18
19
20
21
22
# File 'lib/sprockets/helpers/asset_path.rb', line 18

def to_a
  @asset.to_a.map do |dependency|
    AssetPath.new(@uri.clone, dependency, @options.merge(:body => true)).to_s
  end
end