Class: Lev::TransactionIsolation
- Defined in:
- lib/lev/transaction_isolation.rb
Instance Attribute Summary collapse
-
#symbol ⇒ Object
readonly
Returns the value of attribute symbol.
Class Method Summary collapse
- .mysql_default ⇒ Object
- .no_transaction ⇒ Object
- .read_committed ⇒ Object
- .read_uncommitted ⇒ Object
- .repeatable_read ⇒ Object
- .serializable ⇒ Object
Instance Method Summary collapse
- #==(other) ⇒ Object
- #eql?(other) ⇒ Boolean
-
#initialize(symbol) ⇒ TransactionIsolation
constructor
A new instance of TransactionIsolation.
- #replace_if_more_isolated(other_transaction_isolation) ⇒ Object
- #weaker_than(other) ⇒ Object
Constructor Details
#initialize(symbol) ⇒ TransactionIsolation
Returns a new instance of TransactionIsolation.
4 5 6 7 |
# File 'lib/lev/transaction_isolation.rb', line 4 def initialize(symbol) raise Lev.configuration.illegal_argument_error, "Invalid isolation symbol" if !@@symbols_to_isolation_levels.has_key?(symbol) @symbol = symbol end |
Instance Attribute Details
#symbol ⇒ Object
Returns the value of attribute symbol.
40 41 42 |
# File 'lib/lev/transaction_isolation.rb', line 40 def symbol @symbol end |
Class Method Details
.mysql_default ⇒ Object
27 28 29 30 |
# File 'lib/lev/transaction_isolation.rb', line 27 def self.mysql_default # MySQL default per https://blog.engineyard.com/2010/a-gentle-introduction-to-isolation-levels repeatable_read end |
.no_transaction ⇒ Object
9 |
# File 'lib/lev/transaction_isolation.rb', line 9 def self.no_transaction; new(:no_transaction); end |
.read_committed ⇒ Object
11 |
# File 'lib/lev/transaction_isolation.rb', line 11 def self.read_committed; new(:read_committed); end |
.read_uncommitted ⇒ Object
10 |
# File 'lib/lev/transaction_isolation.rb', line 10 def self.read_uncommitted; new(:read_uncommitted); end |
.repeatable_read ⇒ Object
12 |
# File 'lib/lev/transaction_isolation.rb', line 12 def self.repeatable_read; new(:repeatable_read); end |
.serializable ⇒ Object
13 |
# File 'lib/lev/transaction_isolation.rb', line 13 def self.serializable; new(:serializable); end |
Instance Method Details
#==(other) ⇒ Object
32 33 34 |
# File 'lib/lev/transaction_isolation.rb', line 32 def ==(other) self.symbol == other.symbol end |
#eql?(other) ⇒ Boolean
36 37 38 |
# File 'lib/lev/transaction_isolation.rb', line 36 def eql?(other) self == other end |
#replace_if_more_isolated(other_transaction_isolation) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/lev/transaction_isolation.rb', line 16 def replace_if_more_isolated(other_transaction_isolation) if other_transaction_isolation.isolation_level > self.isolation_level self.symbol = other_transaction_isolation.symbol end self end |
#weaker_than(other) ⇒ Object
23 24 25 |
# File 'lib/lev/transaction_isolation.rb', line 23 def weaker_than(other) self.isolation_level < other.isolation_level end |