mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Simplify CallbackTemplate#expand
This commit is contained in:
parent
165c5e5668
commit
6e47695370
1 changed files with 9 additions and 13 deletions
|
@ -129,7 +129,7 @@ module ActiveSupport
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
current.invoke_after(env)
|
current.invoke_after(env)
|
||||||
skipped.pop.invoke_after(env) while skipped && skipped.first
|
skipped.pop.invoke_after(env) while skipped&.first
|
||||||
break env.value
|
break env.value
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -401,21 +401,17 @@ module ActiveSupport
|
||||||
# The actual invocation is left up to the caller to minimize
|
# The actual invocation is left up to the caller to minimize
|
||||||
# call stack pollution.
|
# call stack pollution.
|
||||||
def expand(target, value, block)
|
def expand(target, value, block)
|
||||||
result = @arguments.map { |arg|
|
expanded = [@override_target || target, @override_block || block, @method_name]
|
||||||
|
|
||||||
|
@arguments.each do |arg|
|
||||||
case arg
|
case arg
|
||||||
when :value; value
|
when :value then expanded << value
|
||||||
when :target; target
|
when :target then expanded << target
|
||||||
when :block; block || raise(ArgumentError)
|
when :block then expanded << (block || raise(ArgumentError))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
}
|
|
||||||
|
|
||||||
result.unshift @method_name
|
expanded
|
||||||
result.unshift @override_block || block
|
|
||||||
result.unshift @override_target || target
|
|
||||||
|
|
||||||
# target, block, method, *arguments = result
|
|
||||||
# target.send(method, *arguments, &block)
|
|
||||||
result
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Return a lambda that will make this call when given the input
|
# Return a lambda that will make this call when given the input
|
||||||
|
|
Loading…
Reference in a new issue