Class: N1Loader::ArLazyPreload::AssociatedContextBuilder
- Inherits:
-
ArLazyPreload::AssociatedContextBuilder
- Object
- ArLazyPreload::AssociatedContextBuilder
- N1Loader::ArLazyPreload::AssociatedContextBuilder
- Defined in:
- lib/n1_loader/ar_lazy_preload/associated_context_builder.rb
Overview
Context builder for N1Loader
Instance Attribute Summary collapse
-
#records ⇒ Object
readonly
Returns the value of attribute records.
Instance Method Summary collapse
-
#initialize(parent_context:, association_name:, records:) ⇒ AssociatedContextBuilder
constructor
A new instance of AssociatedContextBuilder.
- #perform ⇒ Object
Constructor Details
#initialize(parent_context:, association_name:, records:) ⇒ AssociatedContextBuilder
Returns a new instance of AssociatedContextBuilder.
9 10 11 12 |
# File 'lib/n1_loader/ar_lazy_preload/associated_context_builder.rb', line 9 def initialize(parent_context:, association_name:, records:) super(parent_context: parent_context, association_name: association_name) @records = records end |
Instance Attribute Details
#records ⇒ Object (readonly)
Returns the value of attribute records.
7 8 9 |
# File 'lib/n1_loader/ar_lazy_preload/associated_context_builder.rb', line 7 def records @records end |
Instance Method Details
#perform ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/n1_loader/ar_lazy_preload/associated_context_builder.rb', line 14 def perform ::ArLazyPreload::Context.register( records: records.flatten(1).select { |record| record.respond_to?(:lazy_preload_context=) }, association_tree: child_association_tree, auto_preload: parent_context.auto_preload? ) end |