diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-02-22 15:32:35 +1100 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-03-04 10:52:07 -0800 |
commit | 54f9b7584dc145963e2b9bffb0963c9f45ff8528 (patch) | |
tree | dbcf0ccc91e179a94244f43619554f11f11ae825 /activesupport/lib/active_support | |
parent | b359c5db9f0e7dfb2cbf34362a9b310cf5aadd3a (diff) | |
download | rails-54f9b7584dc145963e2b9bffb0963c9f45ff8528.tar.gz rails-54f9b7584dc145963e2b9bffb0963c9f45ff8528.tar.bz2 rails-54f9b7584dc145963e2b9bffb0963c9f45ff8528.zip |
only calculate next_id when we need a new method defined
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r-- | activesupport/lib/active_support/callbacks.rb | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/callbacks.rb b/activesupport/lib/active_support/callbacks.rb index e3e1845868..f2d9df6d13 100644 --- a/activesupport/lib/active_support/callbacks.rb +++ b/activesupport/lib/active_support/callbacks.rb @@ -255,7 +255,6 @@ module ActiveSupport # a method is created that calls the before_foo method # on the object. def _compile_filter(filter) - method_name = "_callback_#{@kind}_#{next_id}" case filter when Array filter.map {|f| _compile_filter(f)} @@ -264,11 +263,13 @@ module ActiveSupport when String "(#{filter})" when Proc + method_name = "_callback_#{@kind}_#{next_id}" @klass.send(:define_method, method_name, &filter) return method_name if filter.arity <= 0 method_name << (filter.arity == 1 ? "(self)" : " self, Proc.new ") else + method_name = "_callback_#{@kind}_#{next_id}" @klass.send(:define_method, "#{method_name}_object") { filter } _normalize_legacy_filter(kind, filter) |