Module ActiveModel::Observing
In: lib/rails/observers/active_model/observing.rb

Active Model Observers Activation

Methods

Classes and Modules

Module ActiveModel::Observing::ClassMethods

Public Instance methods

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.

[Validate]