module ActiveRecord::Observing::ClassMethods

def inherited(subclass)

Notify observers when the observed class is subclassed.
def inherited(subclass)
  super
  changed
  notify_observers :observed_class_inherited, subclass
end

def instantiate_observers

Instantiate the global Active Record observers.
def instantiate_observers
  return if @observers.blank?
  @observers.each do |observer|
    if observer.respond_to?(:to_sym) # Symbol or String
      observer.to_s.camelize.constantize.instance
    elsif observer.respond_to?(:instance)
      observer.instance
    else
      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"
    end
  end
end

def observers

Gets the current observers.
def observers
  @observers ||= []
end

def observers=(*observers)

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

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

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

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

Activates the observers assigned. Examples:
def observers=(*observers)
  @observers = observers.flatten
end