Sha256: 2726f86fb1fa56e9bbe6e0daa560df6890ff98c3b043dc54513bcdfd273bb3b3

Contents?: true

Size: 830 Bytes

Versions: 1

Compression:

Stored size: 830 Bytes

Contents

# frozen_string_literal: true

module Goldiloader
  module Compatibility
    ACTIVE_RECORD_VERSION = ::Gem::Version.new(::ActiveRecord::VERSION::STRING)
    RAILS_5_2_0 = ACTIVE_RECORD_VERSION == ::Gem::Version.new('5.2.0')
    FROM_EAGER_LOADABLE = ACTIVE_RECORD_VERSION >= ::Gem::Version.new('5.1.5') ||
      (ACTIVE_RECORD_VERSION >= ::Gem::Version.new('5.0.7') && ACTIVE_RECORD_VERSION < ::Gem::Version.new('5.1.0'))
    GROUP_EAGER_LOADABLE = FROM_EAGER_LOADABLE

    def self.rails_4?
      ::ActiveRecord::VERSION::MAJOR == 4
    end

    # See https://github.com/rails/rails/pull/32375
    def self.destroyed_model_associations_eager_loadable?
      !RAILS_5_2_0
    end

    def self.from_eager_loadable?
      FROM_EAGER_LOADABLE
    end

    def self.group_eager_loadable?
      GROUP_EAGER_LOADABLE
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
goldiloader-3.2.0 lib/goldiloader/compatibility.rb