Module: ReactiveObservers::Observable::Base
- Extended by:
- ActiveSupport::Concern
- Includes:
- DbListener
- Included in:
- ActiveRecord::Base
- Defined in:
- lib/reactive_observers/observable/base.rb
Overview
enables class to be observable automatically included to ActiveRecord::Base
Instance Method Summary collapse
-
#process_observer_hook_notification(action, **options) ⇒ Object
process notification from ActiveRecord hooks.
-
#process_observer_notifications(action, **options) ⇒ Object
process observer notification.
-
#remove_observer(observer, **options) ⇒ Array
remove observer for specific object.
Instance Method Details
#process_observer_hook_notification(action, **options) ⇒ Object
process notification from ActiveRecord hooks
88 89 90 91 92 |
# File 'lib/reactive_observers/observable/base.rb', line 88 def process_observer_hook_notification(action, **) return if ReactiveObservers.configuration.observed_tables.include?(self.class.table_name.to_sym) || self.class.active_observers.blank? process_observer_notifications action, ** end |
#process_observer_notifications(action, **options) ⇒ Object
process observer notification
97 98 99 |
# File 'lib/reactive_observers/observable/base.rb', line 97 def process_observer_notifications(action, **) Observable::Notification.new(self, self.class.active_observers, action, ).perform end |
#remove_observer(observer, **options) ⇒ Array
remove observer for specific object
Topic.first.remove_observer(ActivityObserver) # remove observer from first topic
81 82 83 |
# File 'lib/reactive_observers/observable/base.rb', line 81 def remove_observer(observer, **) self.class.remove_observer observer, .merge(constrain: [id]) end |