mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/delegate.rb (Delegator#respond_to_missing): warn if optional
include_private argument is not false. Delegator does (and should) not forward private methods. [ruby-core:26080] * lib/delegate.rb (Delegator#respond_to_missing): instead of redefining #respond_to?, use #respond_to_missing?. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25372 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
9bcccca47a
commit
fbf15be35f
2 changed files with 14 additions and 3 deletions
|
@ -1,3 +1,12 @@
|
|||
Fri Oct 16 19:39:28 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* lib/delegate.rb (Delegator#respond_to_missing): warn if optional
|
||||
include_private argument is not false. Delegator does (and
|
||||
should) not forward private methods. [ruby-core:26080]
|
||||
|
||||
* lib/delegate.rb (Delegator#respond_to_missing): instead of
|
||||
redefining #respond_to?, use #respond_to_missing?.
|
||||
|
||||
Fri Oct 16 18:42:18 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* bootstraptest/test_gc.rb: added tests based on [ruby-dev:39484]
|
||||
|
|
|
@ -146,9 +146,11 @@ class Delegator
|
|||
# Checks for a method provided by this the delegate object by fowarding the
|
||||
# call through \_\_getobj\_\_.
|
||||
#
|
||||
def respond_to?(m, include_private = false)
|
||||
return true if super
|
||||
return self.__getobj__.respond_to?(m, include_private)
|
||||
def respond_to_missing?(m, include_private = false)
|
||||
if include_private
|
||||
warn "#{caller(3)[0]}: delegator does not forward private methods"
|
||||
end
|
||||
self.__getobj__.respond_to?(m)
|
||||
end
|
||||
|
||||
#
|
||||
|
|
Loading…
Reference in a new issue