1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Added that Observers can use the observes class method instead of overwriting self.observed_class()

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@367 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
David Heinemeier Hansson 2005-01-10 16:06:04 +00:00
parent d239ac40fa
commit d5de666056

View file

@ -43,7 +43,11 @@ module ActiveRecord
# The observer can implement callback methods for each of the methods described in the Callbacks module.
class Observer
include Singleton
def self.observe(*models)
define_method(:observed_class) { models }
end
def initialize
[ observed_class ].flatten.each do |klass|
klass.add_observer(self)