Introducing the new binder gem. Read about the impetus for this here and here. Checkout the source here.
Comments
Seems to me you went to an awful lot of trouble just to end up with:
def do_tricks(&b)
instance_eval(&b)
end
Where did you stumble upon this Proc#bind_to method?trans - February 21, 2010 09:56
hi trans. i think it was here that i first found mention of it.
and yeah, definitely for the Dog example, binder is overkill. but if you're developing a large DSL, with all kinds of methods rebinding blocks passed to them to all kinds of closures (not just self), then "bind :some_method, :some_closure" starts to look a little more appealing. or at least it did to me :-) thanks for commenting!moonmaster9000 - February 21, 2010 20:48
I'd suggest removing these aliases from Object. You want to be pretty restrained if you extend a core class, like Object. They almost seem specific to your dog example :)
Thanks for playing but next time review your code and think it through before you release it to the world. Modifying Object like you have is a really bad idea. Even worse are the aliased methods are not general but specific to your example.AnonymousCritic - February 23, 2010 20:14
yeah, good point, i'm removing the ask/teach/beg methods. i still like tell.moonmaster9000 - February 24, 2010 01:52
and to the anon troll: the aliased methods were certainly ill-advised (i was mad with power), but monkey-patching Object is valid in certain circumstances: if your intention is to create a new, pervasive language feature (or essentially, a new dialect), then yeah, monkey-patching Object is fair-game. if, however, you didn't intend to pollute the namespace with what amounts to a new reserved word, but instead, to add some functionality that people can opt-in to, then definitely, monkey-patching Object is a bad idea.moonmaster9000 - February 24, 2010 14:16
Comments