Module: Pangea::Internal::Type::Union Private

Includes:
Converter
Defined in:
lib/pangea/internal/type/union.rb

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Methods included from Converter

#coerce, coerce, dump, type_info

Instance Method Details

#dump(value, state:) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • value (Object)
  • state (Hash{Symbol=>Object})

    .

    @option state [Boolean] :can_retry

Returns:

  • (Object)


51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/pangea/internal/type/union.rb', line 51

def dump(value, state:)
  if (target = resolve_variant(value))
    return Pangea::Internal::Type::Converter.dump(target, value, state: state)
  end

  known_variants.each do
    target = _2.call
    return Pangea::Internal::Type::Converter.dump(target, value, state: state) if target === value
  end

  super
end