https://bugs.ruby-lang.org/https://bugs.ruby-lang.org/favicon.ico?17097754782009-10-16T20:07:06ZRuby Issue Tracking SystemRuby master - Bug #2206: lib/delegate: inconsistency between respond_to? and sendhttps://bugs.ruby-lang.org/issues/2206?journal_id=62722009-10-16T20:07:06Zmatz (Yukihiro Matsumoto)matz@ruby.or.jp
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Closed</i></li><li><strong>% Done</strong> changed from <i>0</i> to <i>100</i></li></ul><p>=begin<br>
This issue was solved with changeset r25372.<br>
Marc-Andre, thank you for your reporting of the issue.<br>
You have greatfully contributed toward Ruby.<br>
May Ruby be with you.</p>
<p>=end</p> Ruby master - Bug #2206: lib/delegate: inconsistency between respond_to? and sendhttps://bugs.ruby-lang.org/issues/2206?journal_id=62902009-10-18T10:42:44Zmatz (Yukihiro Matsumoto)matz@ruby.or.jp
<ul></ul><p>=begin<br>
Hi,</p>
<p>In message "Re: <a href="/issues/2206">[ruby-core:26080]</a> [Bug <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Bug: lib/delegate: inconsistency between respond_to? and send (Closed)" href="https://bugs.ruby-lang.org/issues/2206">#2206</a>] lib/delegate: inconsistency between respond_to? and send"<br>
on Wed, 14 Oct 2009 13:06:09 +0900, Marc-Andre Lafortune <a href="mailto:redmine@ruby-lang.org" class="email">redmine@ruby-lang.org</a> writes:</p>
<p>|require 'delegate'<br>
|class A<br>
| private<br>
| def private_method<br>
| :bar<br>
| end<br>
|end<br>
|<br>
|x = SimpleDelegator.new(A.new)<br>
|x.respond_to?(:private_method, true) # ==> true<br>
|x.send(:private_method) # ==> NoMethodError</p>
<p>|I expected the call to private_method to be delegated. The attached patch fixes the problem. It is not very elegant but I couldn't think of anything better.</p>
<p>No, delegators should only delegate public methods. I will make<br>
#respond_to? to warn if you specify true for its optional argument.</p>
<pre><code> matz.
</code></pre>
<p>=end</p>