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.



105
106
107
# File 'lib/em-synchrony/activerecord.rb', line 105

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

#begin_transaction(options = {}) ⇒ Object

:nodoc:



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

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

#commit_transactionObject

:nodoc:



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

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

#configure_connectionObject



52
53
54
# File 'lib/em-synchrony/activerecord.rb', line 52

def configure_connection
  nil
end

#current_transactionObject

:nodoc:



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

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

#decrement_open_transactionsObject



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

def decrement_open_transactions
  real_connection.open_transactions -= 1
end

#increment_open_transactionsObject



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

def increment_open_transactions
  real_connection.open_transactions += 1
end

#open_transactionsObject



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

def open_transactions
  real_connection.open_transactions
end

#real_connectionObject



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

def real_connection
  @connection.connection
end

#reset_transactionObject

:nodoc:



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

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

#rollback_transactionObject

:nodoc:



94
95
96
# File 'lib/em-synchrony/activerecord.rb', line 94

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

#transaction(*args, &blk) ⇒ Object



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

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

#transaction_open?Boolean



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

def transaction_open?
  current_transaction.open?
end