aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/locking/optimistic.rb
diff options
context:
space:
mode:
authorEmilio Tagua <miloops@gmail.com>2010-11-21 00:51:01 +0800
committerAaron Patterson <aaron.patterson@gmail.com>2010-11-24 01:37:01 +0800
commitd29d793c9096a732274298cdba07c654e9128484 (patch)
treed176fa512fd3cccc41d65db0fd7ec1d9dfb55030 /activerecord/lib/active_record/locking/optimistic.rb
parent6ffe0ef55bbabf59a533402a6420942c7397e441 (diff)
downloadrails-d29d793c9096a732274298cdba07c654e9128484.tar.gz
rails-d29d793c9096a732274298cdba07c654e9128484.tar.bz2
rails-d29d793c9096a732274298cdba07c654e9128484.zip
Don't create local vars.
Diffstat (limited to 'activerecord/lib/active_record/locking/optimistic.rb')
-rw-r--r--activerecord/lib/active_record/locking/optimistic.rb5
1 files changed, 1 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/locking/optimistic.rb b/activerecord/lib/active_record/locking/optimistic.rb
index bf626301f1..9e1a33a6bf 100644
--- a/activerecord/lib/active_record/locking/optimistic.rb
+++ b/activerecord/lib/active_record/locking/optimistic.rb
@@ -110,12 +110,9 @@ module ActiveRecord
return super unless locking_enabled?
if persisted?
- lock_col = self.class.locking_column
- previous_value = send(lock_col).to_i
-
table = self.class.arel_table
predicate = table[self.class.primary_key].eq(id)
- predicate = predicate.and(table[self.class.locking_column].eq(previous_value))
+ predicate = predicate.and(table[self.class.locking_column].eq(send(self.class.locking_column).to_i))
affected_rows = self.class.unscoped.where(predicate).delete_all