Class: Palapala::AssetFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/palapala/asset_helper.rb

Class Method Summary collapse

Class Method Details

.find(path) ⇒ Object



31
32
33
34
35
36
37
38
39
# File 'lib/palapala/asset_helper.rb', line 31

def find(path)
  if Rails.application.assets.respond_to?(:load_path)
    propshaft_asset(path)
  elsif Rails.application.assets.respond_to?(:find_asset)
    sprockets_asset(path)
  else
    nil
  end
end

.propshaft_asset(path) ⇒ Object



41
42
43
# File 'lib/palapala/asset_helper.rb', line 41

def propshaft_asset(path)
  (asset = Rails.application.assets.load_path.find(path)) ? PropshaftAsset.new(asset) : nil
end

.sprockets_asset(path) ⇒ Object



45
46
47
# File 'lib/palapala/asset_helper.rb', line 45

def sprockets_asset(path)
  (asset = Rails.application.assets.find_asset(path)) ? SprocketsAsset.new(asset) : nil
end