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, MutexSystemError, MutexUnlockFailed
Constant Summary collapse
- VERSION =
ActiveRecord::DatabaseMutex version
'3.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
-
.for(name) ⇒ ActiveRecord::DatabaseMutex::Implementation
The for method returns an instance of ActiveRecord::DatabaseMutex::Implementation that is initialized with the given name.
- .included(modul) ⇒ Object
Instance Method Summary collapse
-
#mutex ⇒ ActiveRecord::DatabaseMutex::Implementation
The mutex method returns an instance of ActiveRecord::DatabaseMutex::Implementation that is initialized with the name given by the id, the class and environment variables.
Class Method Details
.for(name) ⇒ ActiveRecord::DatabaseMutex::Implementation
The for method returns an instance of ActiveRecord::DatabaseMutex::Implementation that is initialized with the given name.
45 46 47 |
# File 'lib/active_record/database_mutex.rb', line 45 def self.for(name) Implementation.new(name: name) end |
.included(modul) ⇒ Object
32 33 34 35 36 |
# File 'lib/active_record/database_mutex.rb', line 32 def self.included(modul) modul.instance_eval do extend ClassMethods end end |
Instance Method Details
#mutex ⇒ ActiveRecord::DatabaseMutex::Implementation
The mutex method returns an instance of ActiveRecord::DatabaseMutex::Implementation that is initialized with the name given by the id, the class and environment variables.
69 70 71 72 73 74 75 |
# File 'lib/active_record/database_mutex.rb', line 69 def mutex if persisted? @mutex ||= Implementation.new(name: "#{id}@#{self.class.mutex_name}") else raise MutexInvalidState, "instance #{inspect} not persisted" end end |