Bug or Feature? (proxying methods)

Discussion in 'Ruby' started by yrashk@gmail.com, Dec 29, 2006.

  1. Guest

    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
    , Dec 29, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Richard B. Christ

    Proxying the call to a JNI method

    Richard B. Christ, Aug 4, 2004, in forum: Java
    Replies:
    1
    Views:
    340
    Jim Sculley
    Aug 5, 2004
  2. Jim Campbell
    Replies:
    2
    Views:
    343
    Jim Campbell
    Oct 22, 2003
  3. Chris McCormick

    Proxying object memory for synchronous update.

    Chris McCormick, Apr 2, 2007, in forum: Python
    Replies:
    0
    Views:
    223
    Chris McCormick
    Apr 2, 2007
  4. Jeff Dege

    HTML proxying in ASP.NET?

    Jeff Dege, Oct 2, 2007, in forum: ASP .Net
    Replies:
    3
    Views:
    369
    Jeff Dege
    Oct 5, 2007
  5. Giampaolo Rodolà

    __getattribute__ and methods proxying

    Giampaolo Rodolà, Jun 12, 2010, in forum: Python
    Replies:
    0
    Views:
    240
    Giampaolo Rodolà
    Jun 12, 2010
Loading...

Share This Page