Module: N1Loader::ArLazyPreload::LoaderPatch

Included in:
Loader
Defined in:
lib/n1_loader/ar_lazy_preload/loader_patch.rb

Overview

A patch to Loader to setup lazy context lazily.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#context_setupObject

Returns the value of attribute context_setup.



7
8
9
# File 'lib/n1_loader/ar_lazy_preload/loader_patch.rb', line 7

def context_setup
  @context_setup
end

Instance Method Details

#loadedObject



9
10
11
12
13
14
15
16
17
# File 'lib/n1_loader/ar_lazy_preload/loader_patch.rb', line 9

def loaded
  return @loaded if @loaded

  super

  context_setup&.call(preloaded_records)

  @loaded
end