Как отметил в комментарии Linux_iOS.rb.cpp.c.lisp.m.sh, в этом случае следует использовать метод __send__
, поскольку BasicObject
не определяет метод экземпляра send
:
Object.instance_methods.grep /send/
# => [:send, :public_send, :__send__]
BasicObject.instance_methods.grep /send/
# => [:__send__]
Это может быть подтверждено документами и для BasicObject
.
Отсутствие send
метода экземпляра в классе BasicObect
приводит к следующей цепочке вызовов:
# initial call
ArrayProxy.foo
# there's no class method 'foo', so we go to class 'method_missing' method
ArrayProxy.method_missing :foo
# inside class 'method_missing' we delegate call to new instance using 'send'
ArrayProxy.new.send :foo
# there is no instance method 'send' in ArrayProxy class (and its parent class
# BasicObject) so instance 'method_missing' is called
ArrayProxy.new.method_missing :send, :foo
# instance 'method_missing' delegates call of 'send' method to @array
@array.send :send, :foo
# that is unfolded into regular call of 'send' on @array object
@array.send :foo
# and finally 'foo' is called for @array object
@array.foo
# => NoMethodError: undefined method `foo' for []:Array