News for hackers. Stuff that matters.
Re:Do you know Ruby’s ‘Chainsaw’ method? by draegtun on Thursday October 07, 2010 @10:05AM (#1767847)
Purely for aesthetic reasons.

Instead of:

    builder.person do |b| 
        b.name("Jim")
        b.phone("555-1234")
    end
You could write it like this:

    builder.tag!('person') do |b|
        b.tag!('name', "Jim")
        b.tag!('phone', "555-1234")
    end
Re:Do you know Ruby’s ‘Chainsaw’ method? by scott_s on Thursday October 07, 2010 @10:57AM (#1768033)
Right, which is what I'm trying to understand: what does this allow you to do that is not just a cute way to call a method?

I think the ActiveRecord example below is the answer I'm looking for, since it creates a method at runtime based on information that did not exist until runtime. But I need to read up on it to understand it.

Re:Do you know Ruby’s ‘Chainsaw’ method? by draegtun on Thursday October 07, 2010 @11:18AM (#1768117)
Personally I find aesthetics an important part of programming. If it looks good to me then it often means I'm doing something right!

So I don't view it has cute but more it being succinct.

Re:Do you know Ruby’s ‘Chainsaw’ method? by scott_s on Thursday October 07, 2010 @11:27AM (#1768160)
I also find aesthetics important, but I don't find this more aesthetically pleasing; it pings the "something's wrong" feeling. Being succinct is a goal, but it's not the only goal.
Re:Do you know Ruby’s ‘Chainsaw’ method? by draegtun on Friday October 08, 2010 @04:13AM (#1770991)
Yes its subjective. There will always be a difference in view between what is cute and what is not cute (and also what I think is cute today may also not hold true tomorrow!).
Re:Do you know Ruby’s ‘Chainsaw’ method? by erikpukinskis on Thursday October 07, 2010 @10:30AM (#1767928)
Not sure if Builder does this, but in theory you could even do:

    builder.person do |b| 
        b.name = "Jim"
        b.phone = "555-1234"
    end
Re:Do you know Ruby’s ‘Chainsaw’ method? by draegtun on Thursday October 07, 2010 @10:42AM (#1767968)
Not sure myself but it can also be written like this:

    builder.person do |b| 
        b.name "Jim"
        b.phone "555-1234"
    end