Class: Dragonfly::Middleware

Inherits:
Object
  • Object
show all
Defined in:
lib/dragonfly/middleware.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, dragonfly_app_name, deprecated_arg = nil) ⇒ Middleware

Returns a new instance of Middleware

Raises:

  • (ArgumentError)

4
5
6
7
8
# File 'lib/dragonfly/middleware.rb', line 4

def initialize(app, dragonfly_app_name, deprecated_arg=nil)
  raise ArgumentError, "mounting Dragonfly::Middleware with a mount point is deprecated - just use Dragonfly::Middleware, #{dragonfly_app_name.inspect}" if deprecated_arg
  @app = app
  @dragonfly_app_name = dragonfly_app_name
end

Instance Method Details

#call(env) ⇒ Object


10
11
12
13
14
15
16
17
# File 'lib/dragonfly/middleware.rb', line 10

def call(env)
  response = Dragonfly[@dragonfly_app_name].call(env)
  if response[1]['X-Cascade'] == 'pass'
    @app.call(env)
  else
    response
  end
end