Class: Agentlog::Context
- Inherits:
-
Object
- Object
- Agentlog::Context
- Defined in:
- lib/agentlog/context.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
Returns the value of attribute action.
-
#controller ⇒ Object
Returns the value of attribute controller.
-
#format ⇒ Object
Returns the value of attribute format.
-
#jobs ⇒ Object
readonly
Returns the value of attribute jobs.
-
#method ⇒ Object
Returns the value of attribute method.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#path ⇒ Object
Returns the value of attribute path.
-
#sql_groups ⇒ Object
readonly
Returns the value of attribute sql_groups.
-
#started_at ⇒ Object
Returns the value of attribute started_at.
Instance Method Summary collapse
- #add_job(job:) ⇒ Object
- #add_sql(name:, duration_ms:) ⇒ Object
-
#initialize(path:, method:, controller:, action:, format:, params:) ⇒ Context
constructor
A new instance of Context.
Constructor Details
#initialize(path:, method:, controller:, action:, format:, params:) ⇒ Context
Returns a new instance of Context.
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/agentlog/context.rb', line 13 def initialize(path:, method:, controller:, action:, format:, params:) @path = path @method = method @controller = controller @action = action @format = format @params = params @jobs = [] @sql_groups = Hash.new { |hash, key| hash[key] = { count: 0, duration: 0.0 } } end |
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action.
6 7 8 |
# File 'lib/agentlog/context.rb', line 6 def action @action end |
#controller ⇒ Object
Returns the value of attribute controller.
6 7 8 |
# File 'lib/agentlog/context.rb', line 6 def controller @controller end |
#format ⇒ Object
Returns the value of attribute format.
6 7 8 |
# File 'lib/agentlog/context.rb', line 6 def format @format end |
#jobs ⇒ Object (readonly)
Returns the value of attribute jobs.
5 6 7 |
# File 'lib/agentlog/context.rb', line 5 def jobs @jobs end |
#method ⇒ Object
Returns the value of attribute method.
6 7 8 |
# File 'lib/agentlog/context.rb', line 6 def method @method end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
5 6 7 |
# File 'lib/agentlog/context.rb', line 5 def params @params end |
#path ⇒ Object
Returns the value of attribute path.
6 7 8 |
# File 'lib/agentlog/context.rb', line 6 def path @path end |
#sql_groups ⇒ Object (readonly)
Returns the value of attribute sql_groups.
5 6 7 |
# File 'lib/agentlog/context.rb', line 5 def sql_groups @sql_groups end |
#started_at ⇒ Object
Returns the value of attribute started_at.
6 7 8 |
# File 'lib/agentlog/context.rb', line 6 def started_at @started_at end |
Instance Method Details
#add_job(job:) ⇒ Object
29 30 31 |
# File 'lib/agentlog/context.rb', line 29 def add_job(job:) jobs << job end |
#add_sql(name:, duration_ms:) ⇒ Object
24 25 26 27 |
# File 'lib/agentlog/context.rb', line 24 def add_sql(name:, duration_ms:) sql_groups[name][:count] += 1 sql_groups[name][:duration] += duration_ms end |