Class: Lev::TransactionIsolation

Inherits:
Object
  • Object
show all
Defined in:
lib/lev/transaction_isolation.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(symbol) ⇒ TransactionIsolation

Returns a new instance of TransactionIsolation.

Raises:



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

#symbolObject

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_defaultObject



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_transactionObject



9
# File 'lib/lev/transaction_isolation.rb', line 9

def self.no_transaction;   new(:no_transaction);   end

.read_committedObject



11
# File 'lib/lev/transaction_isolation.rb', line 11

def self.read_committed;   new(:read_committed);   end

.read_uncommittedObject



10
# File 'lib/lev/transaction_isolation.rb', line 10

def self.read_uncommitted; new(:read_uncommitted); end

.repeatable_readObject



12
# File 'lib/lev/transaction_isolation.rb', line 12

def self.repeatable_read;  new(:repeatable_read);  end

.serializableObject



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

Returns:

  • (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