3 ms·
Metaprogramming Ruby [0] explains Ruby's handling of scope really well. Also, you might enjoy a silly gem I wrote a while ago called ghost_attributes [1]. It
by happy4crazy 15y ago
Metaprogramming Ruby [0] explains Ruby's handling of scope really well.
Also, you might enjoy a silly gem I wrote a while ago called ghost_attributes [1]. It uses closures to mimic attr_accessor. The funny thing about it is that your ghost attributes are completely inaccessible from outside the object, unlike normal instance variables, which are always reachable via things like instance_variable_get. Fun/weird stuff :)
[0] http://www.amazon.com/Metaprogramming-Ruby-Program-Like-Pros/dp/1934356476/ref=sr_1_1?ie=UTF8&qid=1303494088&sr=8-1 http://www.amazon.com/Metaprogramming-Ruby-Program-Like-Pros...
[1] https://github.com/happy4crazy/ghost_attributes https://github.com/happy4crazy/ghost_attributes
- skilldrick 15y agoCrazy! Yeah, Metaprogramming Ruby is on my wishlist. I understand why the rules in Ruby are complicated - it's to make the common case simpler. But I still like the simplicity of JavaScript.