Class: N1Loader::LoaderCollection
- Inherits:
-
Object
- Object
- N1Loader::LoaderCollection
- Includes:
- ArLazyPreload::LoaderCollectionPatch
- Defined in:
- lib/n1_loader/core/loader_collection.rb
Overview
The class is used for storing collections of loaders for elements per set of arguments.
Instance Attribute Summary collapse
-
#elements ⇒ Object
readonly
Returns the value of attribute elements.
-
#loader_class ⇒ Object
readonly
Returns the value of attribute loader_class.
Attributes included from ArLazyPreload::LoaderCollectionPatch
Instance Method Summary collapse
-
#initialize(loader_class, elements) ⇒ LoaderCollection
constructor
A new instance of LoaderCollection.
- #with(**args) ⇒ Object
Constructor Details
#initialize(loader_class, elements) ⇒ LoaderCollection
Returns a new instance of LoaderCollection.
8 9 10 11 |
# File 'lib/n1_loader/core/loader_collection.rb', line 8 def initialize(loader_class, elements) @loader_class = loader_class @elements = elements end |
Instance Attribute Details
#elements ⇒ Object (readonly)
Returns the value of attribute elements.
6 7 8 |
# File 'lib/n1_loader/core/loader_collection.rb', line 6 def elements @elements end |
#loader_class ⇒ Object (readonly)
Returns the value of attribute loader_class.
6 7 8 |
# File 'lib/n1_loader/core/loader_collection.rb', line 6 def loader_class @loader_class end |
Instance Method Details
#with(**args) ⇒ Object
13 14 15 16 17 |
# File 'lib/n1_loader/core/loader_collection.rb', line 13 def with(**args) loader = loader_class.new(elements, **args) loaders[loader.cache_key] ||= loader end |