Skip to content

new has_a block

Pretty simple post, but any ruby object can be post conifged in a line with somthing like: => “tony”){|u|}

which is great for active record tests.

Or in a bigger example:

@trip ={|t|!}
@invite1 = => users(:aaron),
                                   :status => Invitation::STATUS_MAYBE){|i|}
@invite1 = => users(:aaron),
                                   :status => Invitation::STATUS_MAYBE){|i|}


  1. Tom wrote:

    Why not just use Invitation#create instead?

    Sunday, September 28, 2008 at 4:32 am | Permalink
  2. admin wrote:

    Good point. A poor choice of examples. I just found it interesting and it illustrates that many methods that you wouldn’t expect have blocks.

    Sunday, September 28, 2008 at 10:32 am | Permalink

Post a Comment

Your email is never published nor shared.