Class: OmniService::Collection
- Inherits:
-
Object
- Object
- OmniService::Collection
- Extended by:
- Dry::Initializer
- Includes:
- Strict
- Defined in:
- lib/omni_service/collection.rb
Overview
Iterates component over arrays in namespaced params and context. Collects results from all iterations; errors include array index in path.
Extracts arrays from params and context. Iteration count is max of array lengths. Missing indices get empty values. Error paths are prefixed with [namespace, index, …].
Instance Method Summary collapse
Methods included from Strict
Instance Method Details
#call(*params, **context) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/omni_service/collection.rb', line 32 def call(*params, **context) params_array = params.map { |param| param.symbolize_keys.fetch(namespace, []) } context_array = context.fetch(namespace, []) size = [*params_array.map(&:size), context_array.size].max results = (0...size).map do |index| call_wrapper(params_array, context_array, context, index) end compose_result(results, context) end |
#signature ⇒ Object
44 45 46 |
# File 'lib/omni_service/collection.rb', line 44 def signature @signature ||= [component_wrapper.signature.first, true] end |