Fix union
parent
14c52208a3
commit
41cc5f082b
|
@ -182,15 +182,14 @@ def Union.new(decoder : CBOR::Decoder)
|
||||||
{% if non_primitives.size == 1 %}
|
{% if non_primitives.size == 1 %}
|
||||||
return {{non_primitives[0]}}.new(decoder)
|
return {{non_primitives[0]}}.new(decoder)
|
||||||
{% else %}
|
{% else %}
|
||||||
string = pull.read_raw
|
|
||||||
{% for type in non_primitives %}
|
{% for type in non_primitives %}
|
||||||
begin
|
begin
|
||||||
return {{type}}.from_json(string)
|
return {{type}}.new(decoder)
|
||||||
rescue CBOR::ParseError
|
rescue CBOR::ParseError
|
||||||
# Ignore
|
# Ignore
|
||||||
end
|
end
|
||||||
{% end %}
|
{% end %}
|
||||||
raise CBOR::ParseError.new("Couldn't parse #{self} from #{string}", *location)
|
raise CBOR::ParseError.new("Couldn't parse #{self}")
|
||||||
{% end %}
|
{% end %}
|
||||||
{% end %}
|
{% end %}
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue