Sha256: b05452e2064076e9375417d5cb6cb22d9040f908fe1b8be8e9427c31caf9e650

Contents?: true

Size: 981 Bytes

Versions: 2

Compression:

Stored size: 981 Bytes

Contents

# frozen_string_literal: true

module Thredded
  module Compat
    class << self
      # @api private
      def rails_gte_60?
        @rails_gte_60 = (Rails.gem_version >= Gem::Version.new('6.0.0')) if @rails_gte_60.nil?
        @rails_gte_60
      end

      # @api private
      def rails_gte_61?
        @rails_gte_61 = (Rails.gem_version >= Gem::Version.new('6.1.0')) if @rails_gte_61.nil?
        @rails_gte_61
      end

      if Rails.gem_version >= Gem::Version.new('7.0.0')
        # @api private
        def association_preloader(records:, associations:, scope:)
          ActiveRecord::Associations::Preloader.new(
            records: records, associations: associations, scope: scope
          ).call
        end
      else
        # @api private
        def association_preloader(records:, associations:, scope:)
          ActiveRecord::Associations::Preloader.new.preload(
            records, associations, scope
          )
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
thredded-1.0.1 lib/thredded/compat.rb
thredded-1.0.0 lib/thredded/compat.rb