Module: ActiveRecordHostPool::DatabaseSwitch
- Defined in:
- lib/active_record_host_pool/connection_adapter_mixin.rb
Instance Attribute Summary collapse
-
#_host_pool_desired_database ⇒ Object
Returns the value of attribute _host_pool_desired_database.
Instance Method Summary collapse
- #create_database ⇒ Object
- #disconnect! ⇒ Object
- #drop_database ⇒ Object
- #initialize ⇒ Object
- #perform_query(raw_connection, intent) ⇒ Object
- #with_raw_connection ⇒ Object
Instance Attribute Details
#_host_pool_desired_database ⇒ Object
Returns the value of attribute _host_pool_desired_database.
17 18 19 |
# File 'lib/active_record_host_pool/connection_adapter_mixin.rb', line 17 def _host_pool_desired_database @_host_pool_desired_database end |
Instance Method Details
#create_database ⇒ Object
53 54 55 56 57 58 |
# File 'lib/active_record_host_pool/connection_adapter_mixin.rb', line 53 def create_database(...) self._no_switch = true super ensure self._no_switch = false end |
#disconnect! ⇒ Object
60 61 62 63 64 |
# File 'lib/active_record_host_pool/connection_adapter_mixin.rb', line 60 def disconnect! @_cached_current_database = nil @_cached_connection_object_id = nil super end |
#drop_database ⇒ Object
46 47 48 49 50 51 |
# File 'lib/active_record_host_pool/connection_adapter_mixin.rb', line 46 def drop_database(...) self._no_switch = true super ensure self._no_switch = false end |
#initialize ⇒ Object
18 19 20 21 |
# File 'lib/active_record_host_pool/connection_adapter_mixin.rb', line 18 def initialize(*) @_cached_current_database = nil super end |
#perform_query(raw_connection, intent) ⇒ Object
40 41 42 43 |
# File 'lib/active_record_host_pool/connection_adapter_mixin.rb', line 40 def perform_query(raw_connection, intent) _switch_connection(raw_connection) if _host_pool_desired_database && !_no_switch super end |
#with_raw_connection ⇒ Object
28 29 30 31 32 33 |
# File 'lib/active_record_host_pool/connection_adapter_mixin.rb', line 28 def with_raw_connection(...) super do |real_connection| _switch_connection(real_connection) if _host_pool_desired_database && !_no_switch yield real_connection end end |