Module: ParamsReady::Marshaller::TupleMarshallers::ArrayMarshaller
- Extended by:
- AbstractMarshaller
- Defined in:
- lib/params_ready/marshaller/tuple_marshallers.rb
Class Method Summary collapse
- .canonicalize(definition, array, context, validator, freeze: false) ⇒ Object
- .do_marshal(fields, _) ⇒ Object
Methods included from AbstractMarshaller
Class Method Details
.canonicalize(definition, array, context, validator, freeze: false) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/params_ready/marshaller/tuple_marshallers.rb', line 25 def self.canonicalize(definition, array, context, validator, freeze: false) if array.length != definition.arity raise ParamsReadyError, "Unexpected array length: #{array.length}" end canonical = definition.fields.each_with_index.map do |field_definition, index| element = field_definition.create element.set_from_input(array[index], context, validator) element.freeze if freeze element end [canonical, validator] end |
.do_marshal(fields, _) ⇒ Object
39 40 41 |
# File 'lib/params_ready/marshaller/tuple_marshallers.rb', line 39 def self.do_marshal(fields, _) fields end |