Class: Bemer::AssetMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/bemer/asset_matcher.rb

Instance Method Summary collapse

Constructor Details

#initialize(loose_app_assets) ⇒ AssetMatcher

Returns a new instance of AssetMatcher.



5
6
7
# File 'lib/bemer/asset_matcher.rb', line 5

def initialize(loose_app_assets)
  @loose_app_assets = loose_app_assets
end

Instance Method Details

#call(logical_path, filename = nil) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/bemer/asset_matcher.rb', line 9

def call(logical_path, filename = nil)
  filename = Rails.application.assets.resolve(logical_path).to_s if filename.nil?

  return if [Bemer.path, *Bemer.asset_paths].detect { |path| filename.start_with?(path.to_s) }

  loose_app_assets.call(logical_path, filename) if loose_app_assets.respond_to?(:call)
end