# frozen_string_literal: true module FreshConnection module Extend module M2Adapter def select_all(*args) change_connection { super } end def select_rows(*args) change_connection { super } end private def change_connection return yield unless FreshConnection::AccessControl.replica_access? master_connection = @connection begin replica_connection = @model_class.replica_connection @connection = replica_connection.raw_connection yield ensure @connection = master_connection end end end end end