mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Use keyword arguments instead of last parameter Hash
this would eliminate warnings when calling keyworded method, and this still works with methods taking last parameter Hash
This commit is contained in:
parent
154b7ffd97
commit
cd31e113c0
1 changed files with 8 additions and 3 deletions
|
@ -14,16 +14,21 @@ module ActiveSupport
|
|||
|
||||
private
|
||||
def method_missing(method, *arguments, &block)
|
||||
options = nil
|
||||
if arguments.first.is_a?(Proc)
|
||||
proc = arguments.pop
|
||||
arguments << lambda { |*args| @options.deep_merge(proc.call(*args)) }
|
||||
elsif arguments.last.respond_to?(:to_hash)
|
||||
arguments << @options.deep_merge(arguments.pop)
|
||||
options = @options.deep_merge(arguments.pop)
|
||||
else
|
||||
arguments << @options.dup
|
||||
options = @options.dup
|
||||
end
|
||||
|
||||
if options
|
||||
@context.__send__(method, *arguments, **options, &block)
|
||||
else
|
||||
@context.__send__(method, *arguments, &block)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue