Class: ActionCost::Middleware

Inherits:
Object
  • Object
show all
Defined in:
lib/action_cost/middleware.rb

Overview

Middleware responsability is to initialize and close RequestStats object at start and end of HTTP query.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Middleware

Returns a new instance of Middleware.



40
41
42
# File 'lib/action_cost/middleware.rb', line 40

def initialize(app)
  @app = app
end

Class Method Details

.accumulated_statsObject



59
60
61
# File 'lib/action_cost/middleware.rb', line 59

def self.accumulated_stats
  action_cost_data.accumulated_stats
end

.action_cost_dataObject



44
45
46
# File 'lib/action_cost/middleware.rb', line 44

def self.action_cost_data
  $action_cost_data
end

.push_sql_parser(parser) ⇒ Object



55
56
57
# File 'lib/action_cost/middleware.rb', line 55

def self.push_sql_parser(parser)
  action_cost_data.push_sql_parser(parser)
end

Instance Method Details

#call(env) ⇒ Object



48
49
50
51
52
53
# File 'lib/action_cost/middleware.rb', line 48

def call(env)
  self.class.action_cost_data.start_request(env)
  @app.call(env)
ensure
  self.class.action_cost_data.end_request
end