diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2010-01-31 18:32:28 -0800 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2010-02-01 02:02:42 -0800 |
commit | e5ab4b0d07ade8d89d633ca744c0eafbc53ee921 (patch) | |
tree | aa2480b38f79e623b98da0274695f99db73bff20 /activerecord/lib | |
parent | 8ae25a8e41168801590fdb95891cc5990b4db21c (diff) | |
download | rails-e5ab4b0d07ade8d89d633ca744c0eafbc53ee921.tar.gz rails-e5ab4b0d07ade8d89d633ca744c0eafbc53ee921.tar.bz2 rails-e5ab4b0d07ade8d89d633ca744c0eafbc53ee921.zip |
Convert to class_attribute
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/observer.rb | 9 |
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" |