class Avro::Builder::Types::UnionType

Constants

NULL_TYPE

Public Class Methods

union_with_null(serialized) click to toggle source

serialized will be an array of types. If the array includes :null then it is moved to the beginning of the array.

# File lib/avro/builder/types/union_type.rb, line 27
def self.union_with_null(serialized)
  serialized.reject { |type| type.to_s == NULL_TYPE }.unshift(:null)
end

Public Instance Methods

logical_type=(value) click to toggle source
# File lib/avro/builder/types/union_type.rb, line 35
def logical_type=(value)
  raise AttributeError.new("Logical types are not supported for unions: #{value}.")
end
serialize(referenced_state) click to toggle source

Unions are serialized as an array of types

# File lib/avro/builder/types/union_type.rb, line 21
def serialize(referenced_state)
  types.map { |type| type.serialize(referenced_state) }
end
validate!() click to toggle source
# File lib/avro/builder/types/union_type.rb, line 31
def validate!
  validate_required_attribute!(:types)
end