Class: Standby::ConnectionHolder

Inherits:
ActiveRecord::Base show all
Defined in:
lib/standby/connection_holder.rb

Class Method Summary collapse

Methods inherited from ActiveRecord::Base

connection, connection_without_standby, on_standby

Class Method Details

.activate(target) ⇒ Object

for delayed activation

Raises:



7
8
9
10
11
# File 'lib/standby/connection_holder.rb', line 7

def activate(target)
  spec = ActiveRecord::Base.configurations["#{ActiveRecord::ConnectionHandling::RAILS_ENV.call}_#{target}"]
  raise Error.new("Standby target '#{target}' is invalid!") if spec.nil?
  establish_connection spec
end