Module: ParamsReady::Marshaller::TupleMarshallers::StructMarshaller

Extended by:
AbstractMarshaller
Defined in:
lib/params_ready/marshaller/tuple_marshallers.rb

Class Method Summary collapse

Methods included from AbstractMarshaller

marshal, marshal_fields

Class Method Details

.canonicalize(definition, hash, context, validator) ⇒ Object



49
50
51
52
53
54
# File 'lib/params_ready/marshaller/tuple_marshallers.rb', line 49

def self.canonicalize(definition, hash, context, validator)
  array = (0...definition.arity).map do |idx|
    Extensions::Hash.indifferent_access(hash, idx, Extensions::Undefined)
  end
  ArrayMarshaller.canonicalize(definition, array, context, validator)
end

.do_marshal(fields, _) ⇒ Object



56
57
58
59
60
# File 'lib/params_ready/marshaller/tuple_marshallers.rb', line 56

def self.do_marshal(fields, _)
  fields.each_with_index.map do |field, index|
    [index.to_s, field]
  end.to_h
end