Class: Avro::Builder::Types::UnionType
- Includes:
- ComplexType, ConfigurableType, TypeReferencer
- Defined in:
- lib/avro/builder/types/union_type.rb
Constant Summary collapse
- NULL_TYPE =
'null'.freeze
Constants included from Avro::Builder::TypeFactory
Avro::Builder::TypeFactory::BUILTIN_TYPES, Avro::Builder::TypeFactory::COMPLEX_TYPES
Instance Attribute Summary
Attributes inherited from Type
Class Method Summary collapse
-
.union_with_null(serialized) ⇒ Object
serialized will be an array of types.
Instance Method Summary collapse
-
#serialize(referenced_state) ⇒ Object
Unions are serialized as an array of types.
- #validate! ⇒ Object
Methods included from TypeReferencer
#create_builtin_or_lookup_named_type
Methods included from ConfigurableType
Methods included from ComplexType
included, #initialize, #namespace
Methods inherited from Type
#cache!, #configure_options, #dsl_method?, #dsl_respond_to?, #initialize, #namespace
Methods included from DslAttributes
Methods included from DslOptions
Class Method Details
.union_with_null(serialized) ⇒ Object
serialized will be an array of types. If the array includes :null then it is moved to the beginning of the array.
26 27 28 |
# File 'lib/avro/builder/types/union_type.rb', line 26 def self.union_with_null(serialized) serialized.reject { |type| type.to_s == NULL_TYPE }.unshift(:null) end |
Instance Method Details
#serialize(referenced_state) ⇒ Object
Unions are serialized as an array of types
20 21 22 |
# File 'lib/avro/builder/types/union_type.rb', line 20 def serialize(referenced_state) types.map { |type| type.serialize(referenced_state) } end |
#validate! ⇒ Object
30 31 32 |
# File 'lib/avro/builder/types/union_type.rb', line 30 def validate! validate_required_attribute!(:types) end |