Module: ActiveRecordHostPool::DatabaseSwitch

Defined in:
lib/active_record_host_pool/connection_adapter_mixin.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#_host_pool_desired_databaseObject

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_databaseObject



42
43
44
45
46
47
# File 'lib/active_record_host_pool/connection_adapter_mixin.rb', line 42

def create_database(...)
  self._no_switch = true
  super
ensure
  self._no_switch = false
end

#disconnect!Object



49
50
51
52
53
# File 'lib/active_record_host_pool/connection_adapter_mixin.rb', line 49

def disconnect!
  @_cached_current_database = nil
  @_cached_connection_object_id = nil
  super
end

#drop_databaseObject



35
36
37
38
39
40
# File 'lib/active_record_host_pool/connection_adapter_mixin.rb', line 35

def drop_database(...)
  self._no_switch = true
  super
ensure
  self._no_switch = false
end

#initializeObject



18
19
20
21
# File 'lib/active_record_host_pool/connection_adapter_mixin.rb', line 18

def initialize(*)
  @_cached_current_database = nil
  super
end

#with_raw_connectionObject



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