Skip to content

Commit

Permalink
Added that Observers can use the observes class method instead of ove…
Browse files Browse the repository at this point in the history
…rwriting self.observed_class()

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@367 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
dhh committed Jan 10, 2005
1 parent d239ac4 commit d5de666
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion activerecord/lib/active_record/observer.rb
Expand Up @@ -43,7 +43,11 @@ module ActiveRecord
# The observer can implement callback methods for each of the methods described in the Callbacks module. # The observer can implement callback methods for each of the methods described in the Callbacks module.
class Observer class Observer
include Singleton include Singleton


def self.observe(*models)
define_method(:observed_class) { models }
end

def initialize def initialize
[ observed_class ].flatten.each do |klass| [ observed_class ].flatten.each do |klass|
klass.add_observer(self) klass.add_observer(self)
Expand Down

0 comments on commit d5de666

Please sign in to comment.