From 84e541ecb41262234afbdff9096258dce77ededa Mon Sep 17 00:00:00 2001 From: Sebastian Martinez Date: Tue, 17 May 2011 20:21:35 -0300 Subject: Better doc styling in ActiveRecord::Locking --- .../lib/active_record/locking/optimistic.rb | 30 +++++++++++----------- .../lib/active_record/locking/pessimistic.rb | 4 +-- 2 files changed, 17 insertions(+), 17 deletions(-) (limited to 'activerecord/lib') diff --git a/activerecord/lib/active_record/locking/optimistic.rb b/activerecord/lib/active_record/locking/optimistic.rb index cdedcde0eb..3afa257a76 100644 --- a/activerecord/lib/active_record/locking/optimistic.rb +++ b/activerecord/lib/active_record/locking/optimistic.rb @@ -3,16 +3,17 @@ module ActiveRecord # == What is Optimistic Locking # # Optimistic locking allows multiple users to access the same record for edits, and assumes a minimum of - # conflicts with the data. It does this by checking whether another process has made changes to a record since - # it was opened, an ActiveRecord::StaleObjectError is thrown if that has occurred and the update is ignored. + # conflicts with the data. It does this by checking whether another process has made changes to a record since + # it was opened, an ActiveRecord::StaleObjectError exception is thrown if that has occurred + # and the update is ignored. # - # Check out ActiveRecord::Locking::Pessimistic for an alternative. + # Check out ActiveRecord::Locking::Pessimistic for an alternative. # # == Usage # - # Active Records support optimistic locking if the field lock_version is present. Each update to the - # record increments the lock_version column and the locking facilities ensure that records instantiated twice - # will let the last one saved raise a StaleObjectError if the first was also updated. Example: + # Active Records support optimistic locking if the field +lock_version+ is present. Each update to the + # record increments the +lock_version+ column and the locking facilities ensure that records instantiated twice + # will let the last one saved raise a +StaleObjectError+ if the first was also updated. Example: # # p1 = Person.find(1) # p2 = Person.find(1) @@ -36,10 +37,10 @@ module ActiveRecord # You're then responsible for dealing with the conflict by rescuing the exception and either rolling back, merging, # or otherwise apply the business logic needed to resolve the conflict. # - # You must ensure that your database schema defaults the lock_version column to 0. + # You must ensure that your database schema defaults the +lock_version+ column to 0. # # This behavior can be turned off by setting ActiveRecord::Base.lock_optimistically = false. - # To override the name of the lock_version column, invoke the set_locking_column method. + # To override the name of the +lock_version+ column, invoke the set_locking_column method. # This method uses the same syntax as set_table_name module Optimistic extend ActiveSupport::Concern @@ -68,9 +69,9 @@ module ActiveRecord result = super # If the locking column has no default value set, - # start the lock version at zero. Note we can't use - # locking_enabled? at this point as @attributes may - # not have been initialized yet + # start the lock version at zero. Note we can't use + # locking_enabled? at this point as + # @attributes may not have been initialized yet. if lock_optimistically && result.include?(self.class.locking_column) result[self.class.locking_column] ||= 0 @@ -137,10 +138,9 @@ module ActiveRecord module ClassMethods DEFAULT_LOCKING_COLUMN = 'lock_version' - # Is optimistic locking enabled for this table? Returns true if the - # +lock_optimistically+ flag is set to true (which it is, by default) - # and the table includes the +locking_column+ column (defaults to - # +lock_version+). + # Returns true if the +lock_optimistically+ flag is set to true + # (which it is, by default) and the table includes the + # +locking_column+ column (defaults to +lock_version+). def locking_enabled? lock_optimistically && columns_hash[locking_column] end diff --git a/activerecord/lib/active_record/locking/pessimistic.rb b/activerecord/lib/active_record/locking/pessimistic.rb index 862cf8f72a..4c4c1bf5a1 100644 --- a/activerecord/lib/active_record/locking/pessimistic.rb +++ b/activerecord/lib/active_record/locking/pessimistic.rb @@ -3,7 +3,7 @@ module ActiveRecord # Locking::Pessimistic provides support for row-level locking using # SELECT ... FOR UPDATE and other lock types. # - # Pass :lock => true to ActiveRecord::Base.find to obtain an exclusive + # Pass :lock => true to ActiveRecord::Base.find to obtain an exclusive # lock on the selected rows: # # select * from accounts where id=1 for update # Account.find(1, :lock => true) @@ -21,7 +21,7 @@ module ActiveRecord # yuko.save! # end # - # You can also use ActiveRecord::Base#lock! method to lock one record by id. + # You can also use ActiveRecord::Base#lock! method to lock one record by id. # This may be better if you don't need to lock every row. Example: # # Account.transaction do -- cgit v1.2.3