__method__
も__callee__
も現在のメソッド名をシンボルで返すのだが、
def method
__method__
end
#=> method
def callee
__callee__
end
#=> callee
alias_methodの時のみ、違いが出る。
class Foo
def old_method
__method__
end
def old_callee
__callee__
end
alias_method :new_method, :old_method
alias_method :new_callee, :old_callee
end
Foo.new.new_method
#=> :old_method
Foo.new.new_callee
#=> :new_callee
__method__
はaliasの元のmethod名が返され、
__callee__
はaliasのmethod名が返される。
alias_methodでなく、aliasの時も、
def old_method
__method__
end
def old_callee
__callee__
end
alias :new_method :old_method
alias :new_callee :old_callee
new_method
#=> :old_method
new_callee
#=> :new_callee