Module ActiveModel::Observing::ClassMethods
In: lib/active_model/observing.rb

Methods

Public Instance methods

Add a new observer to the pool. The new observer needs to respond to ‘update’, otherwise it raises an ArgumentError exception.

Instantiate the global observers.

Notify list of observers of a change.

Gets the current observer instances.

Gets an array of observers observing this model. The array also provides enable and disable methods that allow you to selectively enable and disable observers. (see ActiveModel::ObserverArray.enable and ActiveModel::ObserverArray.disable for more on this)

Active Model Observers Activation

Activates the observers assigned. Examples:

  class ORM
    include ActiveModel::Observing
  end

  # Calls PersonObserver.instance
  ORM.observers = :person_observer

  # Calls Cacher.instance and GarbageCollector.instance
  ORM.observers = :cacher, :garbage_collector

  # Same as above, just using explicit class references
  ORM.observers = Cacher, GarbageCollector

Note: Setting this does not instantiate the observers yet. instantiate_observers is called during startup, and before each development request.

Protected Instance methods

Notify observers when the observed class is subclassed.

[Validate]