Sha256: 92732332df0a1e4f1a34e42121cea19523d82aad723ef274fdbe147b08b18a7a

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

# encoding: UTF-8

module Goldiloader
  class AssociationInfo

    def initialize(association)
      @association = association
    end

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

    def has_one?
      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

1 entries across 1 versions & 1 rubygems

Version Path
goldiloader-2.1.2 lib/goldiloader/association_info.rb