module ArCache::ActiveRecord::Associations::HasOneThroughAssociation

Constants

PRELOADER

Private Instance Methods

find_target() click to toggle source
Calls superclass method
# File lib/ar_cache/active_record/associations/has_one_through_association.rb, line 9
        def find_target
  return super if ArCache.skip_cache?
  return super unless ArCache.cache_reflection?(reflection) do
    ArCache::Query.new(owner.association(through_reflection.name).scope).exec_queries_cacheable? &&
    ArCache::Query.new(source_reflection.active_record.new.association(source_reflection.name).scope).exec_queries_cacheable? # rubocop:disable Layout/LineLength
  end

  if (owner.strict_loading? || reflection.strict_loading?) && owner.validation_context.nil?
    ::ActiveRecord::Base.strict_loading_violation!(owner: owner.class, reflection: reflection)
  end

  PRELOADER.preload(owner, reflection.name)
  target
end