Class: ActiveRecord::Adapter

Inherits:
ConnectionAdapters::Mysql2Adapter
  • Object
show all
Defined in:
lib/emmy_extends/activerecord/adapter.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.



56
57
58
# File 'lib/emmy_extends/activerecord/adapter.rb', line 56

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

#begin_transaction(options = {}) ⇒ Object

:nodoc:



37
38
39
# File 'lib/emmy_extends/activerecord/adapter.rb', line 37

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

#commit_transactionObject

:nodoc:



41
42
43
# File 'lib/emmy_extends/activerecord/adapter.rb', line 41

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

#configure_connectionObject



3
4
5
# File 'lib/emmy_extends/activerecord/adapter.rb', line 3

def configure_connection
  nil
end

#current_transactionObject

:nodoc:



29
30
31
# File 'lib/emmy_extends/activerecord/adapter.rb', line 29

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

#decrement_open_transactionsObject



25
26
27
# File 'lib/emmy_extends/activerecord/adapter.rb', line 25

def decrement_open_transactions
  real_connection.open_transactions -= 1
end

#increment_open_transactionsObject



21
22
23
# File 'lib/emmy_extends/activerecord/adapter.rb', line 21

def increment_open_transactions
  real_connection.open_transactions += 1
end

#open_transactionsObject



17
18
19
# File 'lib/emmy_extends/activerecord/adapter.rb', line 17

def open_transactions
  real_connection.open_transactions
end

#real_connectionObject



13
14
15
# File 'lib/emmy_extends/activerecord/adapter.rb', line 13

def real_connection
  @connection.connection
end

#reset_transactionObject

:nodoc:



49
50
51
52
# File 'lib/emmy_extends/activerecord/adapter.rb', line 49

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

#rollback_transactionObject

:nodoc:



45
46
47
# File 'lib/emmy_extends/activerecord/adapter.rb', line 45

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

#transaction(*args, &blk) ⇒ Object



7
8
9
10
11
# File 'lib/emmy_extends/activerecord/adapter.rb', line 7

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

#transaction_open?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/emmy_extends/activerecord/adapter.rb', line 33

def transaction_open?
  current_transaction.open?
end