Ruby closures borderline macro syntax

(written by lawrence krubner, however indented passages are often quotes). You can contact lawrence at: lawrence@krubner.com

A good reminder of how much block syntax gives you:

    if user.save
      # publish event 'user.created', with payload {user: user}
      Publisher.broadcast_event('user.created', user: user)
    end

    def create_user(params)
      user = User.new(params)

      # publish event 'user.created', with payload {user: user}, using block syntax
      # now the event will have additional data about duration and exceptions
      Publisher.broadcast_event('user.created', user: user) do
        User.save!
        # do some more important stuff here
      end
    end
Source