Module: Serega::SeregaBatch::Loader::InstanceMethods
- Included in:
- Serega::SeregaBatch::Loader
- Defined in:
- lib/serega/batch/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
26 27 28 |
# File 'lib/serega/batch/loader.rb', line 26 def block @block end |
#initials ⇒ Hash (readonly)
BatchLoader initial params
18 19 20 |
# File 'lib/serega/batch/loader.rb', line 18 def initials @initials end |
#name ⇒ Symbol (readonly)
BatchLoader name
22 23 24 |
# File 'lib/serega/batch/loader.rb', line 22 def name @name end |
Instance Method Details
#initialize(name:, block:) ⇒ Object
Initializes new batch loader
34 35 36 37 38 39 40 41 42 |
# File 'lib/serega/batch/loader.rb', line 34 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
48 49 50 51 52 53 54 |
# File 'lib/serega/batch/loader.rb', line 48 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 |