Class: Capybara::Server::Middleware
- Inherits:
-
Object
- Object
- Capybara::Server::Middleware
- Defined in:
- lib/capybara/server.rb
Defined Under Namespace
Classes: Counter
Instance Attribute Summary collapse
-
#error ⇒ Object
Returns the value of attribute error.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ Middleware
constructor
A new instance of Middleware.
- #pending_requests? ⇒ Boolean
Constructor Details
#initialize(app) ⇒ Middleware
Returns a new instance of Middleware.
28 29 30 31 |
# File 'lib/capybara/server.rb', line 28 def initialize(app) @app = app @counter = Counter.new end |
Instance Attribute Details
#error ⇒ Object
Returns the value of attribute error.
26 27 28 |
# File 'lib/capybara/server.rb', line 26 def error @error end |
Instance Method Details
#call(env) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/capybara/server.rb', line 37 def call(env) if env["PATH_INFO"] == "/__identify__" [200, {}, [@app.object_id.to_s]] else @counter.increment begin @app.call(env) rescue *Capybara.server_errors => e @error = e unless @error raise e ensure @counter.decrement end end end |
#pending_requests? ⇒ Boolean
33 34 35 |
# File 'lib/capybara/server.rb', line 33 def pending_requests? @counter.value > 0 end |