diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-04-04 18:19:55 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-04-04 18:19:55 -0300 |
commit | 49a0f554a66ed427df2ab9942e64252b56b60c27 (patch) | |
tree | 4a43bee11e00334458b94deedf776525e727e9ad | |
parent | 02acd95d5700ea868c34f5d260882fda3cc836d3 (diff) | |
download | rails-49a0f554a66ed427df2ab9942e64252b56b60c27.tar.gz rails-49a0f554a66ed427df2ab9942e64252b56b60c27.tar.bz2 rails-49a0f554a66ed427df2ab9942e64252b56b60c27.zip |
Revert "Merge pull request #10034 from benofsky/fix_skipping_object_callback_filters"
This reverts commit c79c6980647eb76bfa52178711fb04ba7e9d403b, reversing
changes made to ba4c27479add60b783a0e623c8a5d176c1dc9043.
This broke all the tests. See https://travis-ci.org/rails/rails/builds/6061839
-rw-r--r-- | activesupport/CHANGELOG.md | 3 | ||||
-rw-r--r-- | activesupport/lib/active_support/callbacks.rb | 14 | ||||
-rw-r--r-- | activesupport/test/callbacks_test.rb | 17 |
3 files changed, 1 insertions, 33 deletions
diff --git a/activesupport/CHANGELOG.md b/activesupport/CHANGELOG.md index 5a7cddb079..31395d6da2 100644 --- a/activesupport/CHANGELOG.md +++ b/activesupport/CHANGELOG.md @@ -14,9 +14,6 @@ *Charles Jones* -* Fix skipping of filters defined by objects in `ActiveSupport::Callbacks::Callback`. - - *Ben McRedmond* ## Rails 4.0.0.beta1 (February 25, 2013) ## diff --git a/activesupport/lib/active_support/callbacks.rb b/activesupport/lib/active_support/callbacks.rb index 4a3636eb56..6c0cae71ed 100644 --- a/activesupport/lib/active_support/callbacks.rb +++ b/activesupport/lib/active_support/callbacks.rb @@ -131,7 +131,6 @@ module ActiveSupport end def matches?(_kind, _filter) - _filter = _method_name_for_object_filter(_kind, _filter) if @_is_object_filter @kind == _kind && @filter == _filter end @@ -235,14 +234,6 @@ module ActiveSupport @compiled_options = conditions.flatten.join(" && ") end - def _method_name_for_object_filter(kind, filter) - class_name = filter.kind_of?(Class) ? filter.to_s : filter.class.to_s - class_name.gsub!(/<|>|#/, '') - class_name.gsub!(/\/|:/, "_") - - "_callback_#{kind}_#{class_name}" - end - # Filters support: # # Arrays:: Used in conditions. This is used to specify @@ -264,8 +255,6 @@ module ActiveSupport # a method is created that calls the before_foo method # on the object. def _compile_filter(filter) - @_is_object_filter = false - case filter when Array filter.map {|f| _compile_filter(f)} @@ -280,8 +269,7 @@ module ActiveSupport method_name << (filter.arity == 1 ? "(self)" : " self, Proc.new ") else - method_name = _method_name_for_object_filter(kind, filter) - @_is_object_filter = true + method_name = "_callback_#{@kind}_#{next_id}" @klass.send(:define_method, "#{method_name}_object") { filter } _normalize_legacy_filter(kind, filter) diff --git a/activesupport/test/callbacks_test.rb b/activesupport/test/callbacks_test.rb index 5afc2094e8..13f2e3cdaf 100644 --- a/activesupport/test/callbacks_test.rb +++ b/activesupport/test/callbacks_test.rb @@ -66,16 +66,6 @@ module CallbacksTest end end - class CallbackClass - def self.before(model) - model.history << [:before_save, :class] - end - - def self.after(model) - model.history << [:after_save, :class] - end - end - class Person < Record [:before_save, :after_save].each do |callback_method| callback_method_sym = callback_method.to_sym @@ -83,7 +73,6 @@ module CallbacksTest send(callback_method, callback_string(callback_method_sym)) send(callback_method, callback_proc(callback_method_sym)) send(callback_method, callback_object(callback_method_sym.to_s.gsub(/_save/, ''))) - send(callback_method, CallbackClass) send(callback_method) { |model| model.history << [callback_method_sym, :block] } end @@ -97,7 +86,6 @@ module CallbacksTest skip_callback :save, :after, :before_save_method, :unless => :yes skip_callback :save, :after, :before_save_method, :if => :no skip_callback :save, :before, :before_save_method, :unless => :no - skip_callback :save, :before, CallbackClass , :if => :yes def yes; true; end def no; false; end end @@ -442,7 +430,6 @@ module CallbacksTest [:before_save, :object], [:before_save, :block], [:after_save, :block], - [:after_save, :class], [:after_save, :object], [:after_save, :proc], [:after_save, :string], @@ -462,10 +449,8 @@ module CallbacksTest [:before_save, :string], [:before_save, :proc], [:before_save, :object], - [:before_save, :class], [:before_save, :block], [:after_save, :block], - [:after_save, :class], [:after_save, :object], [:after_save, :proc], [:after_save, :string], @@ -730,10 +715,8 @@ module CallbacksTest [:before_save, :string], [:before_save, :proc], [:before_save, :object], - [:before_save, :class], [:before_save, :block], [:after_save, :block], - [:after_save, :class], [:after_save, :object], [:after_save, :proc], [:after_save, :string], |