Class: Assets::Redirect::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/assets/redirect/base.rb

Direct Known Subclasses

Propshaft, Sprockets

Instance Method Summary collapse

Constructor Details

#initialize(app, assets_pipeline, public_path: "/public", assets_prefix: "/assets", logger: nil) ⇒ Base

Returns a new instance of Base.



6
7
8
9
10
11
12
# File 'lib/assets/redirect/base.rb', line 6

def initialize(app, assets_pipeline, public_path: "/public", assets_prefix: "/assets", logger: nil)
  @app = app
  @assets_pipeline = assets_pipeline
  @public_path = public_path
  @assets_prefix = assets_prefix
  @logger = logger
end

Instance Method Details

#call(env) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/assets/redirect/base.rb', line 14

def call(env)
  @request = Rack::Request.new(env)

  if should_redirect?
    redirect_to_resolved_version_from_manifest
  else
    @app.call(env)
  end
end