Bug #2206 ยป delegate_send.diff
lib/delegate.rb | ||
---|---|---|
# _obj_ will be delegated to.
|
||
#
|
||
def initialize(obj)
|
||
@access_private = false
|
||
__setobj__(obj)
|
||
end
|
||
... | ... | |
def method_missing(m, *args, &block)
|
||
begin
|
||
target = self.__getobj__
|
||
unless target.respond_to?(m)
|
||
access = @access_private
|
||
@access_private = false
|
||
unless target.respond_to?(m, access)
|
||
super(m, *args, &block)
|
||
else
|
||
target.__send__(m, *args, &block)
|
||
... | ... | |
end
|
||
#
|
||
# Delegation of calls, including the private methods
|
||
#
|
||
def __send__(*args)
|
||
@access_private = true
|
||
super
|
||
ensure
|
||
@access_private = false
|
||
end
|
||
alias_method :send, :__send__
|
||
#
|
||
# Checks for a method provided by this the delegate object by fowarding the
|
||
# call through \_\_getobj\_\_.
|
||
#
|