Module: EM::Synchrony::ActiveRecord::Adapter
- Included in:
- ActiveRecord::ConnectionAdapters::EMMysql2Adapter
- Defined in:
- lib/em-synchrony/activerecord.rb
Instance Method Summary collapse
-
#add_transaction_record(record) ⇒ Object
Register a record with the current transaction so that its after_commit and after_rollback callbacks can be called.
-
#begin_transaction(options = {}) ⇒ Object
:nodoc:.
-
#commit_transaction ⇒ Object
:nodoc:.
- #configure_connection ⇒ Object
-
#current_transaction ⇒ Object
:nodoc:.
- #decrement_open_transactions ⇒ Object
- #increment_open_transactions ⇒ Object
- #open_transactions ⇒ Object
- #real_connection ⇒ Object
-
#reset_transaction ⇒ Object
:nodoc:.
-
#rollback_transaction ⇒ Object
:nodoc:.
- #transaction(*args, &blk) ⇒ Object
- #transaction_open? ⇒ Boolean
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( = {}) #:nodoc: set_current_transaction(current_transaction.begin()) end |
#commit_transaction ⇒ Object
:nodoc:
90 91 92 |
# File 'lib/em-synchrony/activerecord.rb', line 90 def commit_transaction #:nodoc: set_current_transaction(current_transaction.commit) end |
#configure_connection ⇒ Object
52 53 54 |
# File 'lib/em-synchrony/activerecord.rb', line 52 def configure_connection nil end |
#current_transaction ⇒ Object
: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_transactions ⇒ Object
74 75 76 |
# File 'lib/em-synchrony/activerecord.rb', line 74 def decrement_open_transactions real_connection.open_transactions -= 1 end |
#increment_open_transactions ⇒ Object
70 71 72 |
# File 'lib/em-synchrony/activerecord.rb', line 70 def increment_open_transactions real_connection.open_transactions += 1 end |
#open_transactions ⇒ Object
66 67 68 |
# File 'lib/em-synchrony/activerecord.rb', line 66 def open_transactions real_connection.open_transactions end |
#real_connection ⇒ Object
62 63 64 |
# File 'lib/em-synchrony/activerecord.rb', line 62 def real_connection @connection.connection end |
#reset_transaction ⇒ Object
: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_transaction ⇒ Object
: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 |