Class: FlexiRecord::LockMode
- Inherits:
-
Object
- Object
- FlexiRecord::LockMode
- Defined in:
- lib/flexirecord.rb
Overview
Table lock modes are represented by (constant) LockMode objects:
-
LockMode::AccessShare (Acquired by any read operation.)
-
LockMode::RowShare (Acquired for any row-locking operation.)
-
LockMode::RowExclusive (Acquired when data in a table is modified.)
-
LockMode::ShareUpdateExclusive
-
LockMode::Share (Prohibits data changes in the table.)
-
LockMode::ShareRowExclusive (Prohibits data changes and other Share or ShareRowExclusive locks. Used instead of LockMode::Share to prohibit dead locks, where two processes holding share locks want to write to a table.)
-
LockMode::Exclusive (Prohibits anything else than reading from the table.)
-
LockMode::AccessExclusive (Prohibits any other access to the table.)
Constant Summary collapse
new(:access_share, 'ACCESS SHARE MODE', 'AccessShare')
new(:row_share, 'ROW SHARE MODE', 'RowShare')
- RowExclusive =
new(:row_exclusive, 'ROW EXCLUSIVE MODE', 'RowExclusive')
new(:share_update_exclusive, 'SHARE UPDATE EXCLUSIVE MODE', 'ShareUpdateExclusive')
new(:share, 'SHARE MODE', 'Share')
new(:share_row_exclusive, 'SHARE ROW EXCLUSIVE MODE', 'ShareRowExclusive')
- Exclusive =
new(:exclusive, 'EXCLUSIVE MODE', 'Exclusive')
- AccessExclusive =
new(:access_exclusive, 'ACCESS EXCLUSIVE MODE', 'AccessExclusive')
- @@symbols =
{}
Class Method Summary collapse
-
.by_symbol(symbol) ⇒ Object
Returns a LockMode object, matching the given symbol.
Instance Method Summary collapse
-
#initialize(symbol, sql, name) ⇒ LockMode
constructor
Used for generating the constants representing the possible table lock modes.
-
#inspect ⇒ Object
Returns the name of the constant referring to the lock mode.
-
#to_s ⇒ Object
Returns the SQL string representation of the lock mode.
Constructor Details
#initialize(symbol, sql, name) ⇒ LockMode
Used for generating the constants representing the possible table lock modes.
143 144 145 146 147 148 149 |
# File 'lib/flexirecord.rb', line 143 def initialize(symbol, sql, name) @symbol = symbol.to_sym @sql = sql.to_s.dup.freeze @name = name.to_s.dup.freeze @@symbols[@symbol] = self nil end |
Class Method Details
.by_symbol(symbol) ⇒ Object
Returns a LockMode object, matching the given symbol.
138 139 140 |
# File 'lib/flexirecord.rb', line 138 def self.by_symbol(symbol) @@symbols[symbol.to_sym] end |
Instance Method Details
#inspect ⇒ Object
Returns the name of the constant referring to the lock mode.
157 158 159 |
# File 'lib/flexirecord.rb', line 157 def inspect "#{self.class.name}::#{@name}" end |
#to_s ⇒ Object
Returns the SQL string representation of the lock mode.
152 153 154 |
# File 'lib/flexirecord.rb', line 152 def to_s @sql end |