Class: Corn::Rack
- Inherits:
-
Object
- Object
- Corn::Rack
- Defined in:
- lib/corn/rack.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, report_name = "Corn::Rack created at #{Time.now}", sampling_interval = 0.1, output_interval = nil) ⇒ Rack
constructor
A new instance of Rack.
- #terminate ⇒ Object
Constructor Details
#initialize(app, report_name = "Corn::Rack created at #{Time.now}", sampling_interval = 0.1, output_interval = nil) ⇒ Rack
Returns a new instance of Rack.
3 4 5 6 7 8 9 10 |
# File 'lib/corn/rack.rb', line 3 def initialize(app, report_name="Corn::Rack created at #{Time.now}", sampling_interval=0.1, output_interval=nil) @app = app @prof = Corn.profiler(report_name, sampling_interval, output_interval) at_exit { terminate } end |
Instance Method Details
#call(env) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/corn/rack.rb', line 12 def call(env) if Corn.configured? @prof.profile do @app.call(env) end else @app.call(env) end end |
#terminate ⇒ Object
22 23 24 |
# File 'lib/corn/rack.rb', line 22 def terminate @prof.terminate end |