Module ActiveRecord::Observing::ClassMethods
In: vendor/rails/activerecord/lib/active_record/observer.rb

Methods

Public Instance methods

Instantiate the global ActiveRecord observers

[Source]

    # File vendor/rails/activerecord/lib/active_record/observer.rb, line 26
26:       def instantiate_observers
27:         return if @observers.blank?
28:         @observers.each do |observer|
29:           if observer.respond_to?(:to_sym) # Symbol or String
30:             observer.to_s.camelize.constantize.instance
31:           elsif observer.respond_to?(:instance)
32:             observer.instance
33:           else
34:             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"
35:           end
36:         end
37:       end

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

[Source]

    # File vendor/rails/activerecord/lib/active_record/observer.rb, line 21
21:       def observers=(*observers)
22:         @observers = observers.flatten
23:       end

Protected Instance methods

Notify observers when the observed class is subclassed.

[Source]

    # File vendor/rails/activerecord/lib/active_record/observer.rb, line 41
41:         def inherited(subclass)
42:           super
43:           changed
44:           notify_observers :observed_class_inherited, subclass
45:         end

[Validate]