Module: Serega::SeregaEngine::Loader::InstanceMethods
- Included in:
- Serega::SeregaEngine::Loader
- Defined in:
- lib/serega/engine/loader.rb
Overview
BatchLoader instance methods
Instance Attribute Summary collapse
-
#block ⇒ #call
readonly
BatchLoader block.
-
#initials ⇒ Hash
readonly
BatchLoader initial params.
-
#name ⇒ Symbol
readonly
BatchLoader name.
Instance Method Summary collapse
-
#initialize(name:, block:) ⇒ Object
Initializes new batch loader.
-
#load(objects, context) ⇒ void
Serializes values for objects.
Instance Attribute Details
#block ⇒ #call (readonly)
BatchLoader block
29 30 31 |
# File 'lib/serega/engine/loader.rb', line 29 def block @block end |
#initials ⇒ Hash (readonly)
BatchLoader initial params
21 22 23 |
# File 'lib/serega/engine/loader.rb', line 21 def initials @initials end |
#name ⇒ Symbol (readonly)
BatchLoader name
25 26 27 |
# File 'lib/serega/engine/loader.rb', line 25 def name @name end |
Instance Method Details
#initialize(name:, block:) ⇒ Object
Initializes new batch loader
37 38 39 40 41 42 43 44 45 |
# File 'lib/serega/engine/loader.rb', line 37 def initialize(name:, block:) serializer_class = self.class.serializer_class serializer_class::CheckBatchLoaderParams.new(name, block).validate @initials = SeregaUtils::EnumDeepFreeze.call(name: name, block: block) @name = name.to_sym @block = block @signature = SeregaUtils::MethodSignature.call(block, pos_limit: 2, keyword_args: [:ctx]) end |
#load(objects, context) ⇒ void
This method returns an undefined value.
Serializes values for objects
51 52 53 54 55 56 57 |
# File 'lib/serega/engine/loader.rb', line 51 def load(objects, context) case signature when "1" then block.call(objects) when "2" then block.call(objects, context) else block.call(objects, ctx: context) # "1_ctx" end end |