使用带有动态数量的参数的send

dav*_*idb -1 ruby

我想重定向丢失的方法.我有这个代码:

def method_missing(method_name, *arguments, &block)
  ...
  if arguments.any?
    if arguments.count == 1
      self.documentable.send(method_name, arguments.first)
    else
      self.documentable.send(method_name, arguments) # <- HERE IS MY PROBLEM
    end
  else
    self.documentable.send(method_name)
  end
  ...
end
Run Code Online (Sandbox Code Playgroud)

当我在这个具有多个参数的类上调用一个未定义的方法时,该方法被传递给method_missing上面定义的,我得到ArgumentError: wrong number of arguments (1 for 2)因为我传递的参数数组被解释为一个参数.如何使用send动态数量的参数?

lx0*_*0st 5

使用splat self.documentable.send(method_name, *arguments)