Method: Object#public_send

Defined in:
vm_eval.c

- (Object) public_send(symbol[, args...])

Invokes the method identified by symbol, passing it any arguments specified. Unlike send, public_send calls public methods only.

1.public_send(:puts, "hello")  # causes NoMethodError

Returns:



# File 'vm_eval.c'

/*
 *  call-seq:
 *     obj.public_send(symbol [, args...])  -> obj
 *
 *  Invokes the method identified by _symbol_, passing it any
 *  arguments specified. Unlike send, public_send calls public
 *  methods only.
 *
 *     1.public_send(:puts, "hello")  # causes NoMethodError
 */

VALUE
rb_f_public_send(int argc, VALUE *argv, VALUE recv)
{
    return send_internal(argc, argv, recv, CALL_PUBLIC);
}

Comments