Sha256: 7e7fea27e5006bc3b383c7afab21f1b357117b48f837ee240de7e73b78d96b48
Contents?: true
Size: 721 Bytes
Versions: 20
Compression:
Stored size: 721 Bytes
Contents
require 'facets/more/functor.rb' module Kernel #class Object # Returns a Functor that allows one to call any # Kernel or Object method bound to self, making it # possible to bypass overrides of Kernel and Object # methods. # # class A # def object_id ; "OBTUSE" ; end # end # # c = C.new # c.object_id #=> "OBTUSE" # c.__self__.object_id #=> 6664875832 # #-- # Might this be better named as 'object' or '__object__'? # Should this method actually be private? #++ def __self__ @__self__ ||= Functor.new do |meth, *args| # &blk| Object.instance_method(meth).bind(self).call(*args) # ,&blk) end end #alias_method :self, :__self__ end
Version data entries
20 entries across 20 versions & 1 rubygems