Project

General

Profile

Bug #2206 ยป delegate_send.diff

marcandre (Marc-Andre Lafortune), 10/14/2009 01:06 PM

View differences:

lib/delegate.rb
124 124
  # _obj_ will be delegated to.
125 125
  #
126 126
  def initialize(obj)
127
    @access_private = false
127 128
    __setobj__(obj)
128 129
  end
129 130

  
......
131 132
  def method_missing(m, *args, &block)
132 133
    begin
133 134
      target = self.__getobj__
134
      unless target.respond_to?(m)
135
      access = @access_private
136
      @access_private = false
137
      unless target.respond_to?(m, access)
135 138
        super(m, *args, &block)
136 139
      else
137 140
        target.__send__(m, *args, &block)
......
143 146
  end
144 147

  
145 148
  #
149
  # Delegation of calls, including the private methods
150
  #
151
  def __send__(*args)
152
    @access_private = true
153
    super
154
  ensure
155
    @access_private = false
156
  end
157

  
158
  alias_method :send, :__send__
159

  
160
  #
146 161
  # Checks for a method provided by this the delegate object by fowarding the
147 162
  # call through \_\_getobj\_\_.
148 163
  #