Class: Rmetrics::Events
- Inherits:
-
Object
- Object
- Rmetrics::Events
- Defined in:
- lib/rmetrics/events.rb
Overview
Handles action events across rails
Instance Attribute Summary collapse
-
#db_client ⇒ Object
readonly
Returns the value of attribute db_client.
Instance Method Summary collapse
- #cable_subscribe_events ⇒ Object
- #controller_subscribe_events ⇒ Object
-
#initialize ⇒ Events
constructor
A new instance of Events.
- #job_subscribe_events ⇒ Object
- #mailer_subscribe_events ⇒ Object
- #notification_subscription(action_name) ⇒ Object
- #record_subscribe_events ⇒ Object
- #storage_subscribe_events ⇒ Object
- #support_subscribe_events ⇒ Object
- #view_subscribe_events ⇒ Object
Constructor Details
Instance Attribute Details
#db_client ⇒ Object (readonly)
Returns the value of attribute db_client.
6 7 8 |
# File 'lib/rmetrics/events.rb', line 6 def db_client @db_client end |
Instance Method Details
#cable_subscribe_events ⇒ Object
55 56 57 58 59 |
# File 'lib/rmetrics/events.rb', line 55 def cable_subscribe_events Rmetrics.action_cable.each do |action| notification_subscription(action.to_s) end end |
#controller_subscribe_events ⇒ Object
19 20 21 22 23 |
# File 'lib/rmetrics/events.rb', line 19 def controller_subscribe_events Rmetrics.action_controller.each do |action| notification_subscription(action.to_s) end end |
#job_subscribe_events ⇒ Object
49 50 51 52 53 |
# File 'lib/rmetrics/events.rb', line 49 def job_subscribe_events Rmetrics.active_job.each do |action| notification_subscription(action.to_s) end end |
#mailer_subscribe_events ⇒ Object
37 38 39 40 41 |
# File 'lib/rmetrics/events.rb', line 37 def mailer_subscribe_events Rmetrics.action_mailer.each do |action| notification_subscription(action.to_s) end end |
#notification_subscription(action_name) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/rmetrics/events.rb', line 12 def notification_subscription(action_name) ActiveSupport::Notifications.subscribe(action_name) do |*args| event = ActiveSupport::Notifications::Event.new(*args) @db_client.write_data(action_name, event) end end |
#record_subscribe_events ⇒ Object
31 32 33 34 35 |
# File 'lib/rmetrics/events.rb', line 31 def record_subscribe_events Rmetrics.active_record.each do |action| notification_subscription(action.to_s) end end |
#storage_subscribe_events ⇒ Object
61 62 63 64 65 |
# File 'lib/rmetrics/events.rb', line 61 def storage_subscribe_events Rmetrics.active_storage.each do |action| notification_subscription(action.to_s) end end |
#support_subscribe_events ⇒ Object
43 44 45 46 47 |
# File 'lib/rmetrics/events.rb', line 43 def support_subscribe_events Rmetrics.active_support.each do |action| notification_subscription(action.to_s) end end |
#view_subscribe_events ⇒ Object
25 26 27 28 29 |
# File 'lib/rmetrics/events.rb', line 25 def view_subscribe_events Rmetrics.active_view.each do |action| notification_subscription(action.to_s) end end |