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
- #execute ⇒ Object
- #initialize ⇒ Object
- #with_raw_connection ⇒ Object
- #with_trilogy_connection ⇒ Object
Instance Attribute Details
#_host_pool_desired_database ⇒ Object
Returns the value of attribute _host_pool_desired_database.
20 21 22 |
# File 'lib/active_record_host_pool/connection_adapter_mixin.rb', line 20 def _host_pool_desired_database @_host_pool_desired_database end |
Instance Method Details
#create_database ⇒ Object
59 60 61 62 63 64 |
# File 'lib/active_record_host_pool/connection_adapter_mixin.rb', line 59 def create_database(...) self._no_switch = true super ensure self._no_switch = false end |
#disconnect! ⇒ Object
66 67 68 69 70 |
# File 'lib/active_record_host_pool/connection_adapter_mixin.rb', line 66 def disconnect! @_cached_current_database = nil @_cached_connection_object_id = nil super end |
#drop_database ⇒ Object
52 53 54 55 56 57 |
# File 'lib/active_record_host_pool/connection_adapter_mixin.rb', line 52 def drop_database(...) self._no_switch = true super ensure self._no_switch = false end |
#execute ⇒ Object
46 47 48 49 |
# File 'lib/active_record_host_pool/connection_adapter_mixin.rb', line 46 def execute(...) _switch_connection(raw_connection) if _host_pool_desired_database && !_no_switch super end |
#initialize ⇒ Object
21 22 23 24 |
# File 'lib/active_record_host_pool/connection_adapter_mixin.rb', line 21 def initialize(*) @_cached_current_database = nil super end |
#with_raw_connection ⇒ Object
32 33 34 35 36 37 |
# File 'lib/active_record_host_pool/connection_adapter_mixin.rb', line 32 def with_raw_connection(...) super do |real_connection| _switch_connection(real_connection) if _host_pool_desired_database && !_no_switch yield real_connection end end |
#with_trilogy_connection ⇒ Object
39 40 41 42 43 44 |
# File 'lib/active_record_host_pool/connection_adapter_mixin.rb', line 39 def with_trilogy_connection(...) super do |real_connection| _switch_connection(real_connection) if _host_pool_desired_database && !_no_switch yield real_connection end end |