aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support
diff options
context:
space:
mode:
authorYehuda Katz <wycats@yehuda-katzs-macbookpro41.local>2009-06-02 22:35:28 -0700
committerMichael Koziarski <michael@koziarski.com>2009-06-09 19:47:53 +1200
commit114e25e7359a76e07114f9914a0fb9baecc67644 (patch)
tree9369cfaab984d4a7e948e53a295fcb95c264630c /activesupport/lib/active_support
parent8cae3cd0cf2ae75e0489f9b3e9ac3ab5be89630a (diff)
downloadrails-114e25e7359a76e07114f9914a0fb9baecc67644.tar.gz
rails-114e25e7359a76e07114f9914a0fb9baecc67644.tar.bz2
rails-114e25e7359a76e07114f9914a0fb9baecc67644.zip
Further cleanup of callbacks
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r--activesupport/lib/active_support/new_callbacks.rb17
1 files changed, 7 insertions, 10 deletions
diff --git a/activesupport/lib/active_support/new_callbacks.rb b/activesupport/lib/active_support/new_callbacks.rb
index 0fe3ee4bad..bc340fccec 100644
--- a/activesupport/lib/active_support/new_callbacks.rb
+++ b/activesupport/lib/active_support/new_callbacks.rb
@@ -360,8 +360,9 @@ 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, callbacks)
- body = callbacks.compile(nil, :terminator => send("_#{symbol}_terminator"))
+ def _define_runner(symbol)
+ body = send("_#{symbol}_callbacks").
+ compile(nil, :terminator => send("_#{symbol}_terminator"))
body, line = <<-RUBY_EVAL, __LINE__
def _run_#{symbol}_callbacks(key = nil, &blk)
@@ -437,9 +438,11 @@ module ActiveSupport
callbacks = send("_#{name}_callbacks")
yield callbacks, type, filters, options if block_given?
- _define_runner(name, callbacks)
+ _define_runner(name)
end
+ alias_method :_reset_callbacks, :_update_callbacks
+
def set_callback(name, *filters, &block)
_update_callbacks(name, filters, block) do |callbacks, type, filters, options|
filters.map! do |filter|
@@ -477,13 +480,7 @@ module ActiveSupport
CallbackChain.new(symbol)
end
- self.class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
- def self.reset_#{symbol}_callbacks
- _update_callbacks(:#{symbol})
- end
-
- self.set_callback(:#{symbol}, :before)
- RUBY_EVAL
+ _define_runner(symbol)
end
end
end