Sha256: 6adb97a9316cbb0fd102de66cadb4c67cc1f1a72772602bf78fcce3ac5c1f210

Contents?: true

Size: 905 Bytes

Versions: 4

Compression:

Stored size: 905 Bytes

Contents

# encoding: UTF-8

module Goldiloader
  class AssociationInfo

    def initialize(association)
      @association = association
    end

    delegate :association_scope, :reflection, to: :@association

    def offset?
      association_scope && association_scope.offset_value.present?
    end

    def limit?
      association_scope && association_scope.limit_value.present?
    end

    def auto_include?
      association_scope.nil? || association_scope.auto_include_value
    end

    def from?
      if ActiveRecord::VERSION::MAJOR >= 5
        association_scope && association_scope.from_clause.present?
      else
        association_scope && association_scope.from_value.present?
      end
    end

    def group?
      association_scope && association_scope.group_values.present?
    end

    def instance_dependent?
      reflection.scope.present? && reflection.scope.arity > 0
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
goldiloader-2.1.1 lib/goldiloader/association_info.rb
goldiloader-2.1.0 lib/goldiloader/association_info.rb
goldiloader-2.0.1 lib/goldiloader/association_info.rb
goldiloader-2.0.0 lib/goldiloader/association_info.rb