aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/observer.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/observer.rb b/activerecord/lib/active_record/observer.rb
index ceba78b043..f08374596d 100644
--- a/activerecord/lib/active_record/observer.rb
+++ b/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)