提交 35c4a2ca 编写于 作者: A Aaron Patterson

extract callback param munging

上级 0b9b132e
......@@ -437,12 +437,17 @@ def __callback_runner_name(kind)
__callback_runner_name_cache[kind]
end
# This is used internally to append, prepend and skip callbacks to the
# CallbackChain.
def __update_callbacks(name, filters, block) #:nodoc:
def normalize_callback_params(name, filters, block) # :nodoc:
type = CALLBACK_FILTER_TYPES.include?(filters.first) ? filters.shift : :before
options = filters.last.is_a?(Hash) ? filters.pop : {}
filters.unshift(block) if block
[type, filters, options]
end
# This is used internally to append, prepend and skip callbacks to the
# CallbackChain.
def __update_callbacks(name, filters, block) #:nodoc:
type, filters, options = normalize_callback_params(name, filters, block)
([self] + ActiveSupport::DescendantsTracker.descendants(self)).reverse.each do |target|
chain = target.send("_#{name}_callbacks")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册