Sha256: 593f30a20f66d28e9272615056d6f9ce631bea77ead79ee041a8f3861c6039b2

Contents?: true

Size: 825 Bytes

Versions: 8

Compression:

Stored size: 825 Bytes

Contents

module DbCharmer
  module ActiveRecord
    module AssociationPreload
      ASSOCIATION_TYPES = [ :has_one, :has_many, :belongs_to, :has_and_belongs_to_many ]

      def self.extended(base)
        ASSOCIATION_TYPES.each do |association_type|
          base.class_eval <<-EOF, __FILE__, __LINE__ + 1
            def self.preload_#{association_type}_association(records, reflection, preload_options = {})
              if self.db_charmer_top_level_connection? || self.db_charmer_default_connection != reflection.klass.db_charmer_default_connection
                return super(records, reflection, preload_options)
              end
              reflection.klass.on_db(self) do
                super(records, reflection, preload_options)
              end
            end
          EOF
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
db-charmer-1.7.0 lib/db_charmer/active_record/association_preload.rb
db-charmer-1.7.0.pre7 lib/db_charmer/active_record/association_preload.rb
db-charmer-1.7.0.pre6 lib/db_charmer/active_record/association_preload.rb
db-charmer-1.7.0.pre5 lib/db_charmer/active_record/association_preload.rb
db-charmer-1.7.0.pre4 lib/db_charmer/active_record/association_preload.rb
db-charmer-1.7.0.pre3 lib/db_charmer/active_record/association_preload.rb
db-charmer-1.7.0.pre2 lib/db_charmer/active_record/association_preload.rb
db-charmer-1.7.0.pre1 lib/db_charmer/active_record/association_preload.rb