Forum: Ruby Dynamic Monkey patching of getter / setter methods?

Posted by Jan Luehr (Guest)
on 2010-09-01 21:55
(Received via mailing list)
Hello folks,

I'm playing around with dynamic monkey-patching of methods. However, I
run into syntax errors of my generated code:
ruby monkey.rb
Two: unpatched
---
Patched test_two called
Two: patched
monkey.rb:12:in `catch_method': (eval):4:in `catch_method': compile
error (SyntaxError)
(eval):3: syntax error, unexpected ',', expecting '='
         old_test_attribute=(*args,&block)
                                   ^
  from monkey.rb:33

Do you know a way for dynamic monkey-patching of getter / setter 
methods?

(source at: http://pastie.org/1132204)

Thanks,
Keep smiling
yanosz
Posted by Brian Candler (candlerb)
on 2010-09-01 22:08
Jan Luehr wrote:
> Do you know a way for dynamic monkey-patching of getter / setter 
> methods?

Try using send:

send(:foo=, *args, &block)
Posted by Jan Luehr (Guest)
on 2010-09-01 23:10
(Received via mailing list)
Hello,

Am 01.09.10 22:10, schrieb Brian Candler:
> Jan Luehr wrote:
>> Do you know a way for dynamic monkey-patching of getter / setter
>> methods?
>
> Try using send:
>
> send(:foo=, *args,&block)

thanks - missed that one ;-)

Keep smiling
yanosz
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.