Class: Healthyr::Event
- Inherits:
-
Object
- Object
- Healthyr::Event
- Defined in:
- lib/healthyr/event.rb
Instance Attribute Summary collapse
-
#event ⇒ Object
Returns the value of attribute event.
Instance Method Summary collapse
-
#initialize(*args) ⇒ Event
constructor
A new instance of Event.
- #to_hash ⇒ Object
Constructor Details
#initialize(*args) ⇒ Event
Returns a new instance of Event.
5 6 7 |
# File 'lib/healthyr/event.rb', line 5 def initialize(*args) @event = ActiveSupport::Notifications::Event.new(*args) end |
Instance Attribute Details
#event ⇒ Object
Returns the value of attribute event.
3 4 5 |
# File 'lib/healthyr/event.rb', line 3 def event @event end |
Instance Method Details
#to_hash ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/healthyr/event.rb', line 9 def to_hash {reported_at: Time.at(event.time), time: {total: event.duration}}.tap do |hash| if database? hash[:name] = 'database' hash[:value] = payload[:sql] elsif view? hash[:name] = 'view' hash[:value] = payload[:virtual_path] elsif controller? hash[:name] = 'controller' hash[:value] = "#{payload[:controller]}##{payload[:action]}" hash[:time][:view] = payload[:view_runtime] hash[:time][:db] = payload[:db_runtime] end end end |