Module: ActiveRecord::DatabaseMutex
- Defined in:
- lib/active_record/database_mutex.rb,
lib/active_record/database_mutex/version.rb,
lib/active_record/database_mutex/implementation.rb
Overview
This module is mixed into ActiveRecord::Base to provide the mutex methods that return a mutex for a particular ActiveRecord::Base subclass/instance.
Defined Under Namespace
Modules: ClassMethods Classes: Implementation, MutexError, MutexInvalidState, MutexLocked, MutexUnlockFailed
Constant Summary collapse
- VERSION =
ActiveRecord::DatabaseMutex version
'2.0.0'- VERSION_ARRAY =
:nodoc:
VERSION.split('.').map(&:to_i)
- VERSION_MAJOR =
:nodoc:
VERSION_ARRAY[0]
- VERSION_MINOR =
:nodoc:
VERSION_ARRAY[1]
- VERSION_BUILD =
:nodoc:
VERSION_ARRAY[2]
Class Method Summary collapse
Instance Method Summary collapse
-
#mutex ⇒ Object
Returns a mutex instance for this ActiveRecord instance.
Class Method Details
.for(name) ⇒ Object
XXX
29 30 31 |
# File 'lib/active_record/database_mutex.rb', line 29 def self.for(name) Implementation.new(:name => name) end |
.included(modul) ⇒ Object
22 23 24 25 26 |
# File 'lib/active_record/database_mutex.rb', line 22 def self.included(modul) modul.instance_eval do extend ClassMethods end end |
Instance Method Details
#mutex ⇒ Object
Returns a mutex instance for this ActiveRecord instance.
41 42 43 44 45 46 47 |
# File 'lib/active_record/database_mutex.rb', line 41 def mutex if persisted? @mutex ||= Implementation.new(:name => "#{id}@#{self.class.name}") else raise MutexInvalidState, "instance #{inspect} not persisted" end end |