Sha256: 134960d0d4c8a4917e2ca6b69b230bed09be42ff95f67d5d7918ecd54c0dcca0

Contents?: true

Size: 732 Bytes

Versions: 6

Compression:

Stored size: 732 Bytes

Contents

module Kernel

  # Call parent class/module methods once bound to self.

  def send_as( ancestor, sym, *args, &blk )
    ancestor.instance_method(sym).bind(self).call(*args,&blk)
  end

#--
#   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

6 entries across 6 versions & 1 rubygems

Version Path
facets-1.8.20 lib/facets/core/kernel/send_as.rb
facets-1.8.0 lib/facets/core/kernel/send_as.rb
facets-1.8.49 lib/facets/core/kernel/send_as.rb
facets-1.8.51 lib/facets/core/kernel/send_as.rb
facets-1.8.54 lib/facets/core/kernel/send_as.rb
facets-1.8.8 lib/facets/core/kernel/send_as.rb