Sha256: 3e705170627cd6912a48f017b4faf6776794f5117934a408f58f5d7e7361771d
Contents?: true
Size: 600 Bytes
Versions: 10
Compression:
Stored size: 600 Bytes
Contents
class Object # Call parent class/module methods once bound to self. def send_as(klass, meth, *args, &blk) selfclass = Kernel.instance_method(:class).bind(self).call raise ArgumentError if ! selfclass.ancestors.include?(klass) klass.instance_method(meth).bind(self).call(*args, &blk) end end # _____ _ # |_ _|__ ___| |_ # | |/ _ \/ __| __| # | | __/\__ \ |_ # |_|\___||___/\__| # =begin test require 'test/unit' class TCKernel < Test::Unit::TestCase def test_send_as assert_equal( String, "A".send_as(Object, :class) ) end end =end
Version data entries
10 entries across 10 versions & 1 rubygems