Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added that Observers can use the observes class method instead of ove…

…rwriting self.observed_class()

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@367 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit d5de6660561cf544a33d7d678d693a7b7139f61f 1 parent d239ac4
@dhh dhh authored
Showing with 5 additions and 1 deletion.
  1. +5 −1 activerecord/lib/active_record/observer.rb
View
6 activerecord/lib/active_record/observer.rb
@@ -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)
Please sign in to comment.
Something went wrong with that request. Please try again.