Class: Timber::Events::ControllerCall
- Inherits:
-
Timber::Event
- Object
- Timber::Event
- Timber::Events::ControllerCall
- Defined in:
- lib/timber/events/controller_call.rb
Overview
Note:
This event should be installed automatically through probes, such as the Probes::ActionControllerLogSubscriber probe.
The controller call event tracks controller invocations. For example, this line in Rails:
Processing by PagesController#home as HTML
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#controller ⇒ Object
readonly
Returns the value of attribute controller.
-
#format ⇒ Object
readonly
Returns the value of attribute format.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Instance Method Summary collapse
- #as_json(_options = {}) ⇒ Object
-
#initialize(attributes) ⇒ ControllerCall
constructor
A new instance of ControllerCall.
- #message ⇒ Object
- #to_hash ⇒ Object (also: #to_h)
Constructor Details
#initialize(attributes) ⇒ ControllerCall
Returns a new instance of ControllerCall.
12 13 14 15 16 17 |
# File 'lib/timber/events/controller_call.rb', line 12 def initialize(attributes) @controller = attributes[:controller] || raise(ArgumentError.new(":controller is required")) @action = attributes[:action] || raise(ArgumentError.new(":action is required")) @params = attributes[:params] @format = attributes[:format] end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
10 11 12 |
# File 'lib/timber/events/controller_call.rb', line 10 def action @action end |
#controller ⇒ Object (readonly)
Returns the value of attribute controller.
10 11 12 |
# File 'lib/timber/events/controller_call.rb', line 10 def controller @controller end |
#format ⇒ Object (readonly)
Returns the value of attribute format.
10 11 12 |
# File 'lib/timber/events/controller_call.rb', line 10 def format @format end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
10 11 12 |
# File 'lib/timber/events/controller_call.rb', line 10 def params @params end |
Instance Method Details
#as_json(_options = {}) ⇒ Object
24 25 26 |
# File 'lib/timber/events/controller_call.rb', line 24 def as_json( = {}) {:server_side_app => {:controller_call => to_hash}} end |
#message ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/timber/events/controller_call.rb', line 28 def = "Processing by #{controller}##{action}" if !.nil? << " as #{format}" end if !params.nil? && params.length > 0 << "\n Parameters: #{params.inspect}" end end |
#to_hash ⇒ Object Also known as: to_h
19 20 21 |
# File 'lib/timber/events/controller_call.rb', line 19 def to_hash {controller: controller, action: action} end |