diff options
author | Yehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com> | 2009-06-01 15:40:11 -0700 |
---|---|---|
committer | Yehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com> | 2009-06-01 15:40:40 -0700 |
commit | 196f780e30fcece25e4d09c12f9b9f7374ebed29 (patch) | |
tree | 5bdfa9f486aea64c05ad54137e6f4ec3e04623ba /activesupport | |
parent | dcba6e114884d993089fc1aa47bfaa7c4258a536 (diff) | |
download | rails-196f780e30fcece25e4d09c12f9b9f7374ebed29.tar.gz rails-196f780e30fcece25e4d09c12f9b9f7374ebed29.tar.bz2 rails-196f780e30fcece25e4d09c12f9b9f7374ebed29.zip |
Get all the callback tests to work on new base
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/lib/active_support/new_callbacks.rb | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/activesupport/lib/active_support/new_callbacks.rb b/activesupport/lib/active_support/new_callbacks.rb index 8512c659b0..58d4c47ccb 100644 --- a/activesupport/lib/active_support/new_callbacks.rb +++ b/activesupport/lib/active_support/new_callbacks.rb @@ -286,7 +286,14 @@ module ActiveSupport filter when Proc @klass.send(:define_method, method_name, &filter) - method_name << (filter.arity == 1 ? "(self)" : "") + method_name << case filter.arity + when 1 + "(self)" + when 2 + " self, Proc.new " + else + "" + end when Method @klass.send(:define_method, "#{method_name}_method") { filter } @klass.class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1 @@ -378,7 +385,7 @@ module ActiveSupport # The _run_save_callbacks method can optionally take a key, which # will be used to compile an optimized callback method for each # key. See #define_callbacks for more information. - def _define_runner(symbol, str, options) + def _define_runner(symbol, str, options) str = <<-RUBY_EVAL def _run_#{symbol}_callbacks(key = nil) if key @@ -492,7 +499,7 @@ module ActiveSupport filter = self._#{symbol}_callbacks.find {|c| c.matches?(type, :#{symbol}, filter) } per_key = options[:per_key] || {} - if filter + if filter && options.any? filter.recompile!(options, per_key) else self._#{symbol}_callbacks.delete(filter) |