# Bug or Feature? (proxying methods)

**URL:** <https://www.ruby-forum.com/t/bug-or-feature-proxying-methods/80623>\
**Category:** Ruby\
**Created:** [December 29, 2006, 12:15pm UTC](https://www.ruby-forum.com/t/bug-or-feature-proxying-methods/80623 "2006-12-29T12:15:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [December 29, 2006, 12:15pm UTC](https://www.ruby-forum.com/t/bug-or-feature-proxying-methods/80623/1 "2006-12-29T12:15:35Z")

</div>

I have the following code:

class ReturnSelfAfter

def initialize(context)  
@context = context  
end

def method\_missing(sym,\*args,&block)  
@context.send sym, \*args, &block  
@context  
end

end

class Object  
def return\_self\_after  
ReturnSelfAfter.new(self)  
end  
end

While it works fine proxying most of methods (not inclusive standard  
ones, of course), it seems to fail on setters:

class C ; attr\_accessor :abc ; end

> > C.new.return\_self\_after.abc = 1  
> > =\> 1

While #abc returns C class instance, of course:

> > C.new.return\_self\_after.abc  
> > =\> #\<C:0x705014\>

So, is it a bug or a feature? Or am I just missing something?

(ruby 1.8.4 (2005-12-24) [i686-darwin8.7.1])

Thank you in advance

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [December 29, 2006, 1:15pm UTC](https://www.ruby-forum.com/t/bug-or-feature-proxying-methods/80623/2 "2006-12-29T13:15:45Z")

</div>

On Fri, 29 Dec 2006 11:12:54 -0000, removed\_email\_address@domain.invalid [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> ```
> @context
> 
> ```
> 
> While it works fine proxying most of methods (not inclusive standard  
> =\> #\<C:0x705014\>
> 
> So, is it a bug or a feature? Or am I just missing something?

It’s a feature - assignment in ruby always returns the assigned value,  
no  
matter what you try to return from the method. I guess it’s a question  
of  
consistency.
