Module: EM::Synchrony::ActiveRecord::Adapter

Included in:
ActiveRecord::ConnectionAdapters::EMMysql2Adapter
Defined in:
lib/em-synchrony/activerecord.rb

Instance Method Summary collapse

Instance Method Details

#add_transaction_record(record) ⇒ Object

Register a record with the current transaction so that its after_commit and after_rollback callbacks can be called.


97
98
99
# File 'lib/em-synchrony/activerecord.rb', line 97

def add_transaction_record(record)
  current_transaction.add_record(record)
end

#begin_transaction(options = {}) ⇒ Object

:nodoc:


78
79
80
# File 'lib/em-synchrony/activerecord.rb', line 78

def begin_transaction(options = {}) #:nodoc:
  set_current_transaction(current_transaction.begin(options))
end

#commit_transactionObject

:nodoc:


82
83
84
# File 'lib/em-synchrony/activerecord.rb', line 82

def commit_transaction #:nodoc:
  set_current_transaction(current_transaction.commit)
end

#configure_connectionObject


44
45
46
# File 'lib/em-synchrony/activerecord.rb', line 44

def configure_connection
  nil
end

#current_transactionObject

:nodoc:


70
71
72
# File 'lib/em-synchrony/activerecord.rb', line 70

def current_transaction #:nodoc:
  @transaction[Fiber.current.object_id] || @closed_transaction
end

#decrement_open_transactionsObject


66
67
68
# File 'lib/em-synchrony/activerecord.rb', line 66

def decrement_open_transactions
  real_connection.open_transactions -= 1
end

#increment_open_transactionsObject


62
63
64
# File 'lib/em-synchrony/activerecord.rb', line 62

def increment_open_transactions
  real_connection.open_transactions += 1
end

#open_transactionsObject


58
59
60
# File 'lib/em-synchrony/activerecord.rb', line 58

def open_transactions
  real_connection.open_transactions
end

#real_connectionObject


54
55
56
# File 'lib/em-synchrony/activerecord.rb', line 54

def real_connection
  @connection.connection
end

#reset_transactionObject

:nodoc:


90
91
92
93
# File 'lib/em-synchrony/activerecord.rb', line 90

def reset_transaction #:nodoc:
  @transaction = {}
  @closed_transaction = ::ActiveRecord::ConnectionAdapters::ClosedTransaction.new(self)
end

#rollback_transactionObject

:nodoc:


86
87
88
# File 'lib/em-synchrony/activerecord.rb', line 86

def rollback_transaction #:nodoc:
  set_current_transaction(current_transaction.rollback)
end

#transaction(*args, &blk) ⇒ Object


48
49
50
51
52
# File 'lib/em-synchrony/activerecord.rb', line 48

def transaction(*args, &blk)
  @connection.execute(false) do |conn|
    super
  end
end

#transaction_open?Boolean

Returns:

  • (Boolean)

74
75
76
# File 'lib/em-synchrony/activerecord.rb', line 74

def transaction_open?
  current_transaction.open?
end