Class: Propshaft::Resolver::Dynamic

Inherits:
Object
  • Object
show all
Defined in:
lib/propshaft/resolver/dynamic.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(load_path:, prefix:) ⇒ Dynamic

Returns a new instance of Dynamic.



5
6
7
# File 'lib/propshaft/resolver/dynamic.rb', line 5

def initialize(load_path:, prefix:)
  @load_path, @prefix = load_path, prefix
end

Instance Attribute Details

#load_pathObject (readonly)

Returns the value of attribute load_path.



3
4
5
# File 'lib/propshaft/resolver/dynamic.rb', line 3

def load_path
  @load_path
end

#prefixObject (readonly)

Returns the value of attribute prefix.



3
4
5
# File 'lib/propshaft/resolver/dynamic.rb', line 3

def prefix
  @prefix
end

Instance Method Details

#read(logical_path, options = {}) ⇒ Object



15
16
17
18
19
# File 'lib/propshaft/resolver/dynamic.rb', line 15

def read(logical_path, options = {})
  if asset = load_path.find(logical_path)
    asset.content(**options)
  end
end

#resolve(logical_path) ⇒ Object



9
10
11
12
13
# File 'lib/propshaft/resolver/dynamic.rb', line 9

def resolve(logical_path)
  if asset = load_path.find(logical_path)
    File.join prefix, asset.digested_path
  end
end