1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Rework NewCallbacks to not require method_missing

This commit is contained in:
Yehuda Katz 2009-03-17 18:05:08 -07:00
parent e6e3e3dfbc
commit fb626ee390

View file

@ -353,7 +353,15 @@ module ActiveSupport
str = <<-RUBY_EVAL
def _run_#{symbol}_callbacks(key = nil)
if key
send("_run__\#{self.class.name.split("::").last}__#{symbol}__\#{key}__callbacks") { yield if block_given? }
name = "_run__\#{self.class.name.split("::").last}__#{symbol}__\#{key}__callbacks"
if respond_to?(name)
send(name) { yield if block_given? }
else
self.class._create_and_run_keyed_callback(
self.class.name.split("::").last,
:#{symbol}, key, self) { yield if block_given? }
end
else
#{str}
end