Class: Timber::Events::TemplateRender
- Inherits:
-
Timber::Event
- Object
- Timber::Event
- Timber::Events::TemplateRender
- Defined in:
- lib/timber/events/template_render.rb
Overview
Note:
This event should be installed automatically through integrations, such as the Integrations::ActionView::LogSubscriber integration.
The template render event track template renderings and their performance.
Instance Attribute Summary collapse
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#time_ms ⇒ Object
readonly
Returns the value of attribute time_ms.
Instance Method Summary collapse
-
#as_json(_options = {}) ⇒ Object
Builds a hash representation containing simple objects, suitable for serialization (JSON).
-
#initialize(attributes) ⇒ TemplateRender
constructor
A new instance of TemplateRender.
- #to_hash ⇒ Object (also: #to_h)
Constructor Details
#initialize(attributes) ⇒ TemplateRender
Returns a new instance of TemplateRender.
12 13 14 15 16 17 |
# File 'lib/timber/events/template_render.rb', line 12 def initialize(attributes) @message = attributes[:message] || raise(ArgumentError.new(":message is required")) @name = attributes[:name] || raise(ArgumentError.new(":name is required")) @time_ms = attributes[:time_ms] || raise(ArgumentError.new(":time_ms is required")) @time_ms = @time_ms.round(6) end |
Instance Attribute Details
#message ⇒ Object (readonly)
Returns the value of attribute message.
10 11 12 |
# File 'lib/timber/events/template_render.rb', line 10 def @message end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/timber/events/template_render.rb', line 10 def name @name end |
#time_ms ⇒ Object (readonly)
Returns the value of attribute time_ms.
10 11 12 |
# File 'lib/timber/events/template_render.rb', line 10 def time_ms @time_ms end |
Instance Method Details
#as_json(_options = {}) ⇒ Object
Builds a hash representation containing simple objects, suitable for serialization (JSON).
25 26 27 |
# File 'lib/timber/events/template_render.rb', line 25 def as_json( = {}) {:template_render => to_hash} end |
#to_hash ⇒ Object Also known as: to_h
19 20 21 |
# File 'lib/timber/events/template_render.rb', line 19 def to_hash {name: name, time_ms: time_ms} end |