Class: ActiveRecordQueryCounter::RackMiddleware
- Inherits:
-
Object
- Object
- ActiveRecordQueryCounter::RackMiddleware
- Defined in:
- lib/active_record_query_counter/rack_middleware.rb
Overview
Rack middleware to count queries on a request.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, thresholds: nil) ⇒ RackMiddleware
constructor
A new instance of RackMiddleware.
Constructor Details
#initialize(app, thresholds: nil) ⇒ RackMiddleware
Returns a new instance of RackMiddleware.
12 13 14 15 |
# File 'lib/active_record_query_counter/rack_middleware.rb', line 12 def initialize(app, thresholds: nil) @app = app @thresholds = thresholds.dup.freeze if thresholds end |
Instance Method Details
#call(env) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/active_record_query_counter/rack_middleware.rb', line 17 def call(env) ActiveRecordQueryCounter.count_queries do ActiveRecordQueryCounter.thresholds.set(@thresholds) if @thresholds @app.call(env) end end |