Methods
Public Instance methods
instantiate_observers()

Instantiate the global Active Record observers.

    # File activerecord/lib/active_record/observer.rb, line 34
34:       def instantiate_observers
35:         return if @observers.blank?
36:         @observers.each do |observer|
37:           if observer.respond_to?(:to_sym) # Symbol or String
38:             observer.to_s.camelize.constantize.instance
39:           elsif observer.respond_to?(:instance)
40:             observer.instance
41:           else
42:             raise ArgumentError, "#{observer} must be a lowercase, underscored class name (or an instance of the class itself) responding to the instance method. Example: Person.observers = :big_brother # calls BigBrother.instance"
43:           end
44:         end
45:       end
observers()

Gets the current observers.

    # File activerecord/lib/active_record/observer.rb, line 29
29:       def observers
30:         @observers ||= []
31:       end
observers=(*observers)

Activates the observers assigned. Examples:

  # Calls PersonObserver.instance
  ActiveRecord::Base.observers = :person_observer

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

  # Same as above, just using explicit class references
  ActiveRecord::Base.observers = Cacher, GarbageCollector

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

    # File activerecord/lib/active_record/observer.rb, line 24
24:       def observers=(*observers)
25:         @observers = observers.flatten
26:       end
Protected Instance methods
inherited(subclass)

Notify observers when the observed class is subclassed.

    # File activerecord/lib/active_record/observer.rb, line 49
49:         def inherited(subclass)
50:           super
51:           changed
52:           notify_observers :observed_class_inherited, subclass
53:         end