Module: NaranyaEcm::Rest::Notifications
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/naranya_ecm/rest/notifications.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #as_notification_payload ⇒ Object
- #finish_notify_state_change! ⇒ Object
- #start_notify_state_change! ⇒ Object
Instance Method Details
#as_notification_payload ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/naranya_ecm/rest/notifications.rb', line 14 def as_notification_payload instance_payload = self.class.as_notification_payload.merge({ id: self.id }) # Include belongs_to references: self.class.reflect_on_all_associations.values.select do |association| association.class.name.demodulize == 'BelongsTo' end.map(&:foreign_key).each do |reference_name| instance_payload[reference_name] = self.public_send reference_name end instance_payload end |
#finish_notify_state_change! ⇒ Object
32 33 34 35 |
# File 'lib/naranya_ecm/rest/notifications.rb', line 32 def finish_notify_state_change! ActiveSupport::Notifications.instrumenter .finish("ncontent_sdk.#{aasm.current_event.to_s.tr('!', '').underscore}", self.as_notification_payload) end |
#start_notify_state_change! ⇒ Object
27 28 29 30 |
# File 'lib/naranya_ecm/rest/notifications.rb', line 27 def start_notify_state_change! ActiveSupport::Notifications.instrumenter .start("ncontent_sdk.#{aasm.current_event.to_s.tr('!', '').underscore}", self.as_notification_payload) end |