Class: ActiveRecord::ConnectionAdapters::ConnectionPool
- Inherits:
-
Object
- Object
- ActiveRecord::ConnectionAdapters::ConnectionPool
- Defined in:
- lib/activerecord_bulkoperation/active_record/adapters/abstract_adapter.rb
Instance Method Summary collapse
- #checkin(connection) ⇒ Object
- #checkout ⇒ Object
- #get_connection ⇒ Object
-
#initialize(spec) ⇒ ConnectionPool
constructor
A new instance of ConnectionPool.
- #log ⇒ Object
- #set_connection(connection) ⇒ Object
-
#super_checkin ⇒ Object
before checkout clear the scheduled operation if necessary.
-
#super_checkout ⇒ Object
after checkout clear the scheduled operation if necessary.
- #super_initialize ⇒ Object
Constructor Details
#initialize(spec) ⇒ ConnectionPool
Returns a new instance of ConnectionPool.
9 10 11 12 |
# File 'lib/activerecord_bulkoperation/active_record/adapters/abstract_adapter.rb', line 9 def initialize(spec) super_initialize(spec) @timeout = 5 end |
Instance Method Details
#checkin(connection) ⇒ Object
41 42 43 44 45 |
# File 'lib/activerecord_bulkoperation/active_record/adapters/abstract_adapter.rb', line 41 def checkin(connection) connection.clear_scheduled_operations if connection.respond_to?('clear_scheduled_operations') connection.connection_listeners.each { |l| l.before_close if l.respond_to?('before_close') } if connection.respond_to?('connection_listeners') super_checkin(connection) end |
#checkout ⇒ Object
32 33 34 35 36 37 |
# File 'lib/activerecord_bulkoperation/active_record/adapters/abstract_adapter.rb', line 32 def checkout @timeout = 5 connection = super_checkout connection.clear_scheduled_operations if connection.respond_to?('clear_scheduled_operations') connection end |
#get_connection ⇒ Object
24 25 26 27 28 |
# File 'lib/activerecord_bulkoperation/active_record/adapters/abstract_adapter.rb', line 24 def get_connection id = ActiveRecord::Base.connection_pool.send :current_connection_id hash = ActiveRecord::Base.connection_pool.instance_variable_get('@reserved_connections') hash[id] end |
#log ⇒ Object
14 15 16 |
# File 'lib/activerecord_bulkoperation/active_record/adapters/abstract_adapter.rb', line 14 def log ActiveRecord::Base.logger end |
#set_connection(connection) ⇒ Object
18 19 20 21 22 |
# File 'lib/activerecord_bulkoperation/active_record/adapters/abstract_adapter.rb', line 18 def set_connection(connection) id = ActiveRecord::Base.connection_pool.send :current_connection_id hash = ActiveRecord::Base.connection_pool.instance_variable_get('@reserved_connections') hash[id] = connection end |
#super_checkin ⇒ Object
before checkout clear the scheduled operation if necessary
40 |
# File 'lib/activerecord_bulkoperation/active_record/adapters/abstract_adapter.rb', line 40 alias_method :super_checkin, :checkin |
#super_checkout ⇒ Object
after checkout clear the scheduled operation if necessary
31 |
# File 'lib/activerecord_bulkoperation/active_record/adapters/abstract_adapter.rb', line 31 alias_method :super_checkout, :checkout |
#super_initialize ⇒ Object
8 |
# File 'lib/activerecord_bulkoperation/active_record/adapters/abstract_adapter.rb', line 8 alias_method :super_initialize, :initialize |