Class: Condenser::Rails::HelperAssetResolvers::Environment

Inherits:
Object
  • Object
show all
Defined in:
lib/condenser/rails/helper.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(view) ⇒ Environment

Returns a new instance of Environment.

Raises:

  • (ArgumentError)


233
234
235
236
237
# File 'lib/condenser/rails/helper.rb', line 233

def initialize(view)
  raise ArgumentError, 'config.assets.resolve_with includes :environment, but app.assets is nil' unless view.assets
  @env = view.assets
  @precompiled_assets = view.assets_precompiled_regexes
end

Instance Method Details

#asset_path(path) ⇒ Object



239
240
241
242
243
244
245
246
# File 'lib/condenser/rails/helper.rb', line 239

def asset_path(path)
  if asset = @env.find(path)
    if !precompiled?(asset.filename)
      raise Condenser::Rails::AssetNotPrecompiledError.new(asset.filename)
    end
    asset.export.path
  end
end

#integrity(path) ⇒ Object



248
249
250
# File 'lib/condenser/rails/helper.rb', line 248

def integrity(path)
  @env.find(path)&.export&.integrity
end

#type(path) ⇒ Object



252
253
254
# File 'lib/condenser/rails/helper.rb', line 252

def type(path)
  @env.find(path)&.export&.type
end