Module: ReactiveObservers::Base
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/reactive_observers/base.rb
Overview
add observe methods to appropriate class
class CustomObserver
include ReactiveObservers::Base
def changed(topic, **observer); end
end
Instance Method Summary collapse
-
#observe(observed, refine: nil, trigger: ReactiveObservers.configuration.default_trigger, notify: nil, **options) ⇒ ReactiveObservers::Observer::Container
create object observer for provided active record object or class.
Instance Method Details
#observe(observed, refine: nil, trigger: ReactiveObservers.configuration.default_trigger, notify: nil, **options) ⇒ ReactiveObservers::Observer::Container
create object observer for provided active record object or class
CustomObserver.new.observe(:topics) # observer is observing Topic klass CustomObserver.new.observe(Topic.first) # observer is observing specific topic
57 58 59 |
# File 'lib/reactive_observers/base.rb', line 57 def observe(observed, refine: nil, trigger: ReactiveObservers.configuration.default_trigger, notify: nil, **) self.class.add_observer_to_observable self, observed, .merge(refine: refine, trigger: trigger, notify: notify) end |