aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/reflection_test.rb
diff options
context:
space:
mode:
authorOlek Janiszewski <olek.janiszewski@gmail.com>2012-01-18 23:03:55 +0100
committerOlek Janiszewski <olek.janiszewski@gmail.com>2012-01-18 23:23:41 +0100
commit7afbc89c37e56531c9ef4e34369e329aab1b21de (patch)
treeb2647a40311d813c21712dd5f78fe53f7b76ede8 /activerecord/test/cases/reflection_test.rb
parent423b2626d85f75bb5fec03909ff8963bded7c7d5 (diff)
downloadrails-7afbc89c37e56531c9ef4e34369e329aab1b21de.tar.gz
rails-7afbc89c37e56531c9ef4e34369e329aab1b21de.tar.bz2
rails-7afbc89c37e56531c9ef4e34369e329aab1b21de.zip
Add ActiveRecord::Base#with_lock
Add a `with_lock` method to ActiveRecord objects, which starts a transaction, locks the object (pessimistically) and yields to the block. The method takes one (optional) parameter and passes it to `lock!`. Before: class Order < ActiveRecord::Base def cancel! transaction do lock! # ... cancelling logic end end end After: class Order < ActiveRecord::Base def cancel! with_lock do # ... cancelling logic end end end
Diffstat (limited to 'activerecord/test/cases/reflection_test.rb')
0 files changed, 0 insertions, 0 deletions