Class: JsRender::Rails::AssetFinder

Inherits:
AssetFinder::Base show all
Defined in:
lib/js_render/rails/asset_finder.rb

Instance Method Summary collapse

Methods inherited from AssetFinder::Base

#find_files, #read_files

Constructor Details

#initializeAssetFinder

Returns a new instance of AssetFinder.



4
5
6
7
8
# File 'lib/js_render/rails/asset_finder.rb', line 4

def initialize
  super
  @environment = ::Rails.application.assets
  @manifest = ::Rails.application.assets_manifest
end

Instance Method Details

#read(path) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/js_render/rails/asset_finder.rb', line 10

def read(path)
  logical_path = path.gsub('app/assets/javascripts/', '')
  if @environment
    @environment[logical_path].to_s
  elsif @manifest.assets[logical_path]
    relative_path = @manifest.assets[logical_path]
    full_path = File.join(@manifest.dir, relative_path)
    File.read full_path
  else
    super path
  end
end