Module: Replidog::Model::ClassMethodsWithReplidogSupport

Defined in:
lib/replidog/model.rb

Instance Method Summary collapse

Instance Method Details

#clear_active_connections!Object



40
41
42
43
# File 'lib/replidog/model.rb', line 40

def clear_active_connections!
  super
  proxy_handler.clear_active_slave_connections! if replicated?
end

#clear_all_connections!Object



50
51
52
53
# File 'lib/replidog/model.rb', line 50

def clear_all_connections!
  super
  proxy_handler.clear_all_slave_connections! if replicated?
end

#clear_reloadable_connections!Object



45
46
47
48
# File 'lib/replidog/model.rb', line 45

def clear_reloadable_connections!
  super
  proxy_handler.clear_reloadable_slave_connections! if replicated?
end

#connected?Boolean

Returns:

  • (Boolean)


32
33
34
35
36
37
38
# File 'lib/replidog/model.rb', line 32

def connected?
  if replicated?
    connection.connected?
  else
    super
  end
end

#connectionObject



22
23
24
25
26
27
28
29
30
# File 'lib/replidog/model.rb', line 22

def connection
  if replicated?
    proxy_handler.retrieve_proxy(self).tap do |proxy|
      proxy.current_model = self
    end
  else
    super
  end
end

#establish_connection(spec = ENV["DATABASE_URL"]) ⇒ Object



16
17
18
19
20
# File 'lib/replidog/model.rb', line 16

def establish_connection(spec = ENV["DATABASE_URL"])
  super
  proxy_handler.remove_connection(self)
  proxy_handler.establish_connection(connection_pool.spec, self)
end