Class: ActiveRecord::Adapter
- Inherits:
-
ConnectionAdapters::Mysql2Adapter
- Object
- ConnectionAdapters::Mysql2Adapter
- ActiveRecord::Adapter
- Defined in:
- lib/emmy_extends/activerecord/adapter.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.
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( = {}) #:nodoc: set_current_transaction(current_transaction.begin()) end |
#commit_transaction ⇒ Object
: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_connection ⇒ Object
3 4 5 |
# File 'lib/emmy_extends/activerecord/adapter.rb', line 3 def configure_connection nil end |
#current_transaction ⇒ Object
: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_transactions ⇒ Object
25 26 27 |
# File 'lib/emmy_extends/activerecord/adapter.rb', line 25 def decrement_open_transactions real_connection.open_transactions -= 1 end |
#increment_open_transactions ⇒ Object
21 22 23 |
# File 'lib/emmy_extends/activerecord/adapter.rb', line 21 def increment_open_transactions real_connection.open_transactions += 1 end |
#open_transactions ⇒ Object
17 18 19 |
# File 'lib/emmy_extends/activerecord/adapter.rb', line 17 def open_transactions real_connection.open_transactions end |
#real_connection ⇒ Object
13 14 15 |
# File 'lib/emmy_extends/activerecord/adapter.rb', line 13 def real_connection @connection.connection end |
#reset_transaction ⇒ Object
: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_transaction ⇒ Object
: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
33 34 35 |
# File 'lib/emmy_extends/activerecord/adapter.rb', line 33 def transaction_open? current_transaction.open? end |