rails/rails — pull request #4503 by exviva (2012-01-17 19:21:40+00:00)
Title: Accept a block passed to pessimistic `lock!`

This allows to shorten a typical idiom of calling the `lock!`
method as first within a transaction:

```ruby
class Order < ActiveRecord::Base
def cancel!
transaction do
lock!
# ... cancelling logic
end
end
end

# becomes:

class Order < ActiveRecord::Base
def cancel!
lock! do
# ... cancelling logic
end
end
end
```

@tenderlove this is the port of #4479 you asked for. Please backport to 3-2-stable as well.