Sha256: 3efc549388df1fe5a1e89b2fd08d71fba400f7b703867d6db78d2416060213d5

Contents?: true

Size: 584 Bytes

Versions: 5

Compression:

Stored size: 584 Bytes

Contents

module EdgeRider
  module PreloadAssociations

    def preload_associations(*args)
      preloader = ActiveRecord::Associations::Preloader

      if preloader.method_defined?(:preload) # Rails 4
        preloader.new.preload(*args)
      else
        preloader.new(*args).run
      end
    end

    if ActiveRecord::Base.respond_to?(:preload_associations, true) # Rails 2/3.0
      ActiveRecord::Base.class_eval do
        class << self
          public :preload_associations
        end
      end
    else # Rails 3.2+
      ActiveRecord::Base.send(:extend, self)
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
edge_rider-1.0.0 lib/edge_rider/preload_associations.rb
edge_rider-0.3.3 lib/edge_rider/preload_associations.rb
edge_rider-0.3.2 lib/edge_rider/preload_associations.rb
edge_rider-0.3.1 lib/edge_rider/preload_associations.rb
edge_rider-0.3.0 lib/edge_rider/preload_associations.rb