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}", output_interval = nil) ⇒ Rack
constructor
A new instance of Rack.
- #terminate ⇒ Object
Constructor Details
#initialize(app, report_name = "Corn::Rack created at #{Time.now}", output_interval = nil) ⇒ Rack
Returns a new instance of Rack.
3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/corn/rack.rb', line 3 def initialize(app, report_name="Corn::Rack created at #{Time.now}", output_interval=nil) @app = app @prof = SamplingProf.new(0.1, true) do |data| Corn.post(StringIO.new(data), report_name) end if output_interval @prof.output_interval = output_interval end end |
Instance Method Details
#call(env) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/corn/rack.rb', line 15 def call(env) if Corn.configured? @prof.profile do @app.call(env) end else @app.call(env) end end |
#terminate ⇒ Object
25 26 27 |
# File 'lib/corn/rack.rb', line 25 def terminate @prof.terminate end |