diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2010-02-01 23:42:38 +0000 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2010-02-01 23:42:38 +0000 |
commit | fdcf4d6c5191b25ee3b6c357dafaf17156eb09d3 (patch) | |
tree | 347f771202054a443f9df23a8f65f91d49a52209 /activerecord | |
parent | 27fa38cc3e162b2f8c4bb2d50130fbc17bad6039 (diff) | |
parent | 16c0d1d3b6089bb4b0b0baf7c3eeb5949f31f02b (diff) | |
download | rails-fdcf4d6c5191b25ee3b6c357dafaf17156eb09d3.tar.gz rails-fdcf4d6c5191b25ee3b6c357dafaf17156eb09d3.tar.bz2 rails-fdcf4d6c5191b25ee3b6c357dafaf17156eb09d3.zip |
Merge remote branch 'mainstream/master'
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/activerecord.gemspec | 2 | ||||
-rw-r--r-- | activerecord/lib/active_record/observer.rb | 9 | ||||
-rw-r--r-- | activerecord/test/cases/helper.rb | 9 |
3 files changed, 8 insertions, 12 deletions
diff --git a/activerecord/activerecord.gemspec b/activerecord/activerecord.gemspec index c84a3ac5a9..4fd1a0213c 100644 --- a/activerecord/activerecord.gemspec +++ b/activerecord/activerecord.gemspec @@ -9,7 +9,7 @@ Gem::Specification.new do |s| s.add_dependency('activesupport', '= 3.0.pre') s.add_dependency('activemodel', '= 3.0.pre') - s.add_dependency('arel', '= 0.2.pre') + s.add_dependency('arel', '~> 0.2.0') s.require_path = 'lib' s.autorequire = 'active_record' 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" diff --git a/activerecord/test/cases/helper.rb b/activerecord/test/cases/helper.rb index fa76e2d57a..9e8bfbbee8 100644 --- a/activerecord/test/cases/helper.rb +++ b/activerecord/test/cases/helper.rb @@ -1,14 +1,7 @@ -begin - require File.expand_path('../../../../vendor/gems/environment', __FILE__) -rescue LoadError -end - -lib = File.expand_path('../../../lib', __FILE__) -$:.unshift(lib) unless $:.include?('lib') || $:.include?(lib) +require File.expand_path('../../../../load_paths', __FILE__) require 'config' -require 'rubygems' require 'test/unit' require 'stringio' |