Sha256: dae18a441a0bdd0a2411366b787e1541e9736e4eac5cf2d66542432f0de3bbb0

Contents?: true

Size: 1.07 KB

Versions: 3

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true

module Goldiloader
  class AssociationInfo

    def initialize(association)
      @association = association
    end

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

    def has_one? # rubocop:disable Naming/PredicateName
      reflection.has_one?
    end

    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 order?
      association_scope && association_scope.order_values.present?
    end

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
goldiloader-3.0.2 lib/goldiloader/association_info.rb
goldiloader-3.0.1 lib/goldiloader/association_info.rb
goldiloader-3.0.0 lib/goldiloader/association_info.rb