class ConAir::ConnectionHandler
Attributes
active[RW]
hijacked_spec[R]
swap_class[R]
Public Class Methods
new(swap_class, hijacked_spec, pools = {})
click to toggle source
Calls superclass method
# File lib/con_air/connection_handler.rb, line 7 def initialize(swap_class, hijacked_spec, pools = {}) super(pools) @hijacked_spec = hijacked_spec @swap_class = swap_class @active = true # Init connections after switching handler ActiveRecord::Base.establish_connection end
Public Instance Methods
establish_connection(name, spec)
click to toggle source
Calls superclass method
# File lib/con_air/connection_handler.rb, line 18 def establish_connection(name, spec) if name == swap_class.name @connection_pools[@hijacked_spec] ||= ActiveRecord::ConnectionAdapters::ConnectionPool.new(@hijacked_spec) @class_to_pool[name] = @connection_pools[@hijacked_spec] else super end end
exist?(config, klass)
click to toggle source
# File lib/con_air/connection_handler.rb, line 27 def exist?(config, klass) hijacked_spec.config == config && swap_class == klass end