Project

General

Profile

Backport #9403 ยป delegate-callee.rb

avdi (Avdi Grimm), 01/12/2014 06:27 PM

 
require "delegate"

class Target
def foo
puts "__callee__ in Target#foo: #{__callee__}"
end
end

class Proxy < SimpleDelegator
def foo
puts "__callee__ in Proxy#foo: #{__callee__}"
super
end
end

class DelegateClassProxy < DelegateClass(Target)
def foo
puts "__callee__ in DelegateClassProxy#foo: #{__callee__}"
super
end
end

puts "Ruby #{RUBY_VERSION}"
Proxy.new(Target.new).foo
DelegateClassProxy.new(Target.new).foo
    (1-1/1)