Module: Panda::Core::Notifications
- Defined in:
- lib/panda/core/notifications.rb
Constant Summary collapse
- USER_CREATED =
Event names following Rails convention: namespace.event
"panda.core.user_created"- USER_LOGIN =
"panda.core.user_login"- USER_LOGOUT =
"panda.core.user_logout"- ADMIN_ACTION =
"panda.core.admin_action"
Class Method Summary collapse
-
.instrument(event_name, payload = {}) ⇒ Object
Instrument a Panda Core event.
-
.subscribe(event_name, &block) ⇒ Object
Subscribe to a Panda Core event.
-
.unsubscribe(subscriber) ⇒ Object
Unsubscribe from a Panda Core event.
Class Method Details
.instrument(event_name, payload = {}) ⇒ Object
Instrument a Panda Core event
28 29 30 31 |
# File 'lib/panda/core/notifications.rb', line 28 def instrument(event_name, payload = {}) event_key = const_get(event_name.to_s.upcase) ActiveSupport::Notifications.instrument(event_key, payload) end |
.subscribe(event_name, &block) ⇒ Object
Subscribe to a Panda Core event
19 20 21 22 |
# File 'lib/panda/core/notifications.rb', line 19 def subscribe(event_name, &block) event_key = const_get(event_name.to_s.upcase) ActiveSupport::Notifications.subscribe(event_key, &block) end |
.unsubscribe(subscriber) ⇒ Object
Unsubscribe from a Panda Core event
34 35 36 |
# File 'lib/panda/core/notifications.rb', line 34 def unsubscribe(subscriber) ActiveSupport::Notifications.unsubscribe(subscriber) end |