Sha256: b4c502cc2ecf0550afd211fa6ed886b3358cb0b6ab2e2821bf8931aeb1263598
Contents?: true
Size: 721 Bytes
Versions: 2
Compression:
Stored size: 721 Bytes
Contents
# frozen_string_literal: true module N1Loader module ArLazyPreload # Context adapter for N1Loader class ContextAdapter attr_reader :context delegate_missing_to :context def initialize(context) @context = context end def try_preload_lazily(association_name) return unless context&.send(:association_needs_preload?, association_name) perform_preloading(association_name) end def perform_preloading(association_name) N1Loader::Preloader.new(records).preload(association_name) AssociatedContextBuilder.prepare( parent_context: self, association_name: association_name ) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
n1_loader-1.1.0 | lib/n1_loader/ar_lazy_preload/context_adapter.rb |
n1_loader-1.0.0 | lib/n1_loader/ar_lazy_preload/context_adapter.rb |