Class: InlineSvg::StaticAssetFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/inline_svg/static_asset_finder.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ StaticAssetFinder

Returns a new instance of StaticAssetFinder.



13
14
15
# File 'lib/inline_svg/static_asset_finder.rb', line 13

def initialize(filename)
  @filename = filename
end

Class Method Details

.find_asset(filename) ⇒ Object



9
10
11
# File 'lib/inline_svg/static_asset_finder.rb', line 9

def self.find_asset(filename)
  new(filename)
end

Instance Method Details

#pathnameObject



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/inline_svg/static_asset_finder.rb', line 17

def pathname
  if ::Rails.application.config.assets.compile
    Pathname.new(::Rails.application.assets[@filename].filename)
  else
    manifest = ::Rails.application.assets_manifest
    asset_path = manifest.assets[@filename]
    unless asset_path.nil?
      ::Rails.root.join(manifest.directory, asset_path)
    end
  end
end