Class: Monty::Watch
- Inherits:
-
Object
- Object
- Monty::Watch
- Defined in:
- lib/monty/watch.rb
Instance Method Summary collapse
-
#_call(env) ⇒ Object
Authorize request.
-
#call(env) ⇒ Object
Rack required method.
-
#initialize(app, &block) ⇒ Watch
constructor
A new instance of Watch.
Constructor Details
#initialize(app, &block) ⇒ Watch
Returns a new instance of Watch.
5 6 7 8 9 |
# File 'lib/monty/watch.rb', line 5 def initialize(app, &block) @app = app instance_eval(&block) if block_given? end |
Instance Method Details
#_call(env) ⇒ Object
Authorize request. Redirect if access is denied.
17 18 19 20 21 22 23 24 25 |
# File 'lib/monty/watch.rb', line 17 def _call(env) delivery = Monty::Delivery.new(env) unless delivery.allowed? return [302, redirect_headers, []] end @app.call(env) end |
#call(env) ⇒ Object
Rack required method. For thread safety, dup self and execute _call
12 13 14 |
# File 'lib/monty/watch.rb', line 12 def call(env) dup._call(env) end |