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.
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( = {}) #:nodoc: set_current_transaction(current_transaction.begin()) end |
#commit_transaction ⇒ Object
:nodoc:
82 83 84 |
# File 'lib/em-synchrony/activerecord.rb', line 82 def commit_transaction #:nodoc: set_current_transaction(current_transaction.commit) end |
#configure_connection ⇒ Object
44 45 46 |
# File 'lib/em-synchrony/activerecord.rb', line 44 def configure_connection nil end |
#current_transaction ⇒ Object
: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_transactions ⇒ Object
66 67 68 |
# File 'lib/em-synchrony/activerecord.rb', line 66 def decrement_open_transactions real_connection.open_transactions -= 1 end |
#increment_open_transactions ⇒ Object
62 63 64 |
# File 'lib/em-synchrony/activerecord.rb', line 62 def increment_open_transactions real_connection.open_transactions += 1 end |
#open_transactions ⇒ Object
58 59 60 |
# File 'lib/em-synchrony/activerecord.rb', line 58 def open_transactions real_connection.open_transactions end |
#real_connection ⇒ Object
54 55 56 |
# File 'lib/em-synchrony/activerecord.rb', line 54 def real_connection @connection.connection end |
#reset_transaction ⇒ Object
: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_transaction ⇒ Object
: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
74 75 76 |
# File 'lib/em-synchrony/activerecord.rb', line 74 def transaction_open? current_transaction.open? end |