Module: ActiveModel::Observing
- Extended by:
- ActiveSupport::Concern
- Included in:
- ActiveRecord::Base
- Defined in:
- lib/rails/observers/active_model/observing.rb
Overview
Active Model Observers Activation
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#notify_observers(method, *extra_args) ⇒ Object
Notify a change to the list of observers.
Instance Method Details
#notify_observers(method, *extra_args) ⇒ Object
Notify a change to the list of observers.
class Foo
include ActiveModel::Observing
attr_accessor :status
end
class FooObserver < ActiveModel::Observer
def on_spec(record, *args)
record.status = true
end
end
Foo.observers = FooObserver
Foo.instantiate_observers # => [FooObserver]
foo = Foo.new
foo.status = false
foo.notify_observers(:on_spec)
foo.status # => true
See ActiveModel::Observing::ClassMethods.notify_observers for more information.
227 228 229 |
# File 'lib/rails/observers/active_model/observing.rb', line 227 def notify_observers(method, *extra_args) self.class.notify_observers(method, self, *extra_args) end |