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.



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_databaseObject



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_databaseObject



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

#executeObject



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

#initializeObject



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_connectionObject



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_connectionObject



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