aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorMikel Lindsaar <raasdnil@gmail.com>2010-02-02 10:51:19 +1100
committerMikel Lindsaar <raasdnil@gmail.com>2010-02-02 10:51:19 +1100
commitd1eed079e1338249aa3b2881d07029ac4e71f4ed (patch)
tree18088ca9388e1b7bd27fffea8cb41fa52b618c34 /activerecord/lib
parentddf2b4add33d5e54c5f5e7adacadbb50d3fa7b52 (diff)
parentb9edb0c60c11025311fb06f2e60b3354f1b6cb09 (diff)
downloadrails-d1eed079e1338249aa3b2881d07029ac4e71f4ed.tar.gz
rails-d1eed079e1338249aa3b2881d07029ac4e71f4ed.tar.bz2
rails-d1eed079e1338249aa3b2881d07029ac4e71f4ed.zip
Merge branch 'master' of git://github.com/rails/rails
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/observer.rb9
1 files changed, 6 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/observer.rb b/activerecord/lib/active_record/observer.rb
index 4e05b819b5..0fbb1f0261 100644
--- a/activerecord/lib/active_record/observer.rb
+++ b/activerecord/lib/active_record/observer.rb
@@ -1,3 +1,5 @@
+require 'active_support/core_ext/class/attribute'
+
module ActiveRecord
# Observer classes respond to lifecycle callbacks to implement trigger-like
# behavior outside the original class. This is a great way to reduce the
@@ -85,7 +87,8 @@ module ActiveRecord
# singletons and that call instantiates and registers them.
#
class Observer < ActiveModel::Observer
- extlib_inheritable_accessor(:observed_methods){ [] }
+ class_attribute :observed_methods
+ self.observed_methods = []
def initialize
super
@@ -93,7 +96,7 @@ module ActiveRecord
end
def self.method_added(method)
- observed_methods << method if ActiveRecord::Callbacks::CALLBACKS.include?(method.to_sym)
+ self.observed_methods += [method] if ActiveRecord::Callbacks::CALLBACKS.include?(method.to_sym)
end
protected
@@ -106,7 +109,7 @@ module ActiveRecord
# Check if a notifier callback was already added to the given class. If
# it was not, add it.
- self.observed_methods.each do |method|
+ self.class.observed_methods.each do |method|
callback = :"_notify_observers_for_#{method}"
if (klass.instance_methods & [callback, callback.to_s]).empty?
klass.class_eval "def #{callback}; notify_observers(:#{method}); end"