module ReplicaPools::Hijack
The hijack is added to ActiveRecord::Base but only applies to its descendants. The Base.connection is left in place.
Public Class Methods
extended(base)
click to toggle source
# File lib/replica_pools/hijack.rb, line 5 def self.extended(base) # hijack models that have already been loaded base.send(:descendants).each do |child| child.hijack_connection end end
Public Instance Methods
hijack_connection()
click to toggle source
# File lib/replica_pools/hijack.rb, line 18 def hijack_connection class << self alias_method :connection, :connection_proxy end end
inherited(child)
click to toggle source
hijack models that get loaded later
Calls superclass method
# File lib/replica_pools/hijack.rb, line 13 def inherited(child) super child.hijack_connection end