Class: Harrods::Middleware
- Inherits:
-
Object
- Object
- Harrods::Middleware
- Includes:
- Presenter
- Defined in:
- lib/harrods/middleware.rb
Constant Summary collapse
- TOOLBAR_PATH =
File.("../../../templates/toolbar.erb", __FILE__)
- TOOLBAR =
File.read(TOOLBAR_PATH)
- TOOLBAR_ERB =
Erubis::FastEruby.new(TOOLBAR)
Constants included from Presenter
Presenter::G, Presenter::K, Presenter::M, Presenter::T
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ Middleware
constructor
A new instance of Middleware.
Methods included from Presenter
#present_storage_size, #present_with_commas
Constructor Details
#initialize(app) ⇒ Middleware
Returns a new instance of Middleware.
11 12 13 14 |
# File 'lib/harrods/middleware.rb', line 11 def initialize(app) @db = Harrods::Database.load @app = app end |
Instance Method Details
#call(env) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/harrods/middleware.rb', line 16 def call(env) tracer = Harrods::Tracer.new(@db) status, headers, response, output, ram, objects, gc_runs, gc_time = nil, nil, nil, nil, nil, nil, nil if env['ORIGINAL_FULLPATH'].split("/")[1] == "assets" status, headers, response = @app.call(env) [status, headers, response] else ram, objects, gc_runs, gc_time = tracer.record(env['ORIGINAL_FULLPATH']) do status, headers, response = @app.call(env) end headers, output = inject_this_shizzle(env['ORIGINAL_FULLPATH'], response, headers, ram, objects, gc_runs, gc_time) [status, headers, [output]] end end |