Module: Fingerjam::Helpers

Defined in:
lib/fingerjam/helpers.rb

Instance Method Summary collapse

Instance Method Details

#rewrite_asset_path(source, path = nil) ⇒ Object

Used by Rails view helpers



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/fingerjam/helpers.rb', line 5

def rewrite_asset_path(source, path = nil)
  if Fingerjam::Base.enabled? && Fingerjam::Base.cached?(source)
    Fingerjam::Base.cached_url(source)
  else
    if path && path.respond_to?(:call)
      return path.call(source)
    elsif path && path.is_a?(String)
      return path % [source]
    end

    asset_id = rails_asset_id(source)
    if asset_id.blank?
      source
    else
      source + "?#{asset_id}"
    end
  end
end