module Tarot::Schema::UnionConverter(T)

Overview

UnionConverter will unfold union, try to convert each elements of the union and raise errors if none of the union elements are convertible to T. It can be used directly to create converter which allow union. For example, if you have a custom converter CustomConverter but your field is a union with String, you can do:

field my_field : String|MySpecialType,
      converter: UnionConverter(
                    UniversalConverter(String) | MySpecialTypeConverter
                 )

(note than to convert string you can use UniversalConverter)

Defined in:

tarot/schema/converters.cr

Class Method Summary

Class Method Detail

def self.from_json(json : JSON::Any | Nil, hint = nil, coercive = false) : T #

[View source]