module ParamsReady::Marshaller::TupleMarshallers::ArrayMarshaller

Public Class Methods

canonicalize(definition, array, context, validator, freeze: false) click to toggle source
# 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, _) click to toggle source
# File lib/params_ready/marshaller/tuple_marshallers.rb, line 39
def self.do_marshal(fields, _)
  fields
end