Class: Rails::Application

Inherits:
Object
  • Object
show all
Defined in:
lib/sprockets/railtie.rb

Defined Under Namespace

Classes: Configuration

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#assetsObject

Returns Sprockets::Environment for app config.



31
32
33
# File 'lib/sprockets/railtie.rb', line 31

def assets
  @assets
end

#assets_manifestObject

Returns Sprockets::Manifest for app config.



34
35
36
# File 'lib/sprockets/railtie.rb', line 34

def assets_manifest
  @assets_manifest
end

Instance Method Details

#asset_precompiled?(logical_path) ⇒ Boolean

Called from asset helpers to alert you if you reference an asset URL that isn’t precompiled and hence won’t be available in production.

Returns:

  • (Boolean)


38
39
40
41
42
43
44
45
46
47
# File 'lib/sprockets/railtie.rb', line 38

def asset_precompiled?(logical_path)
  if precompiled_assets.include?(logical_path)
    true
  elsif !config.cache_classes
    # Check to see if precompile list has been updated
    precompiled_assets(true).include?(logical_path)
  else
    false
  end
end

#precompiled_assets(clear_cache = false) ⇒ Object

Lazy-load the precompile list so we don’t cause asset compilation at app boot time, but ensure we cache the list so we don’t recompute it for each request or test case.



52
53
54
55
# File 'lib/sprockets/railtie.rb', line 52

def precompiled_assets(clear_cache = false)
  @precompiled_assets = nil if clear_cache
  @precompiled_assets ||= assets_manifest.find(config.assets.precompile).map(&:logical_path).to_set
end