Sha256: ee8f616d918bc74d667ca2a7163f7a0a82a4e57d6bde44b080f9afc6ce48406d

Contents?: true

Size: 460 Bytes

Versions: 5

Compression:

Stored size: 460 Bytes

Contents

module Autobots
  module Helpers
    module ActiveRecordPreloading
      extend ActiveSupport::Concern

      included do
        class_attribute :preloads
        self.preloads = []
      end

      def transform(objects)
        ActiveRecord::Associations::Preloader.new(objects, preloads).run
        objects
      rescue ArgumentError
        ActiveRecord::Associations::Preloader.new.preload(objects, preloads)
        objects
      end

    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
autobots-0.2.3 lib/autobots/helpers/active_record_preloading.rb
autobots-0.2.2 lib/autobots/helpers/active_record_preloading.rb
autobots-0.2.1 lib/autobots/helpers/active_record_preloading.rb
autobots-0.2.0 lib/autobots/helpers/active_record_preloading.rb
autobots-0.1.0 lib/autobots/helpers/active_record_preloading.rb