Sha256: f9d19f72f4de5a38a0799b785605f016b16a70b62965679b34b3f7efa2e60db7
Contents?: true
Size: 956 Bytes
Versions: 1
Compression:
Stored size: 956 Bytes
Contents
module Avro module Builder module Types class UnionType < Type include Avro::Builder::Types::ComplexType include Avro::Builder::Types::ConfigurableType include Avro::Builder::Types::TypeReferencer NULL_TYPE = 'null'.freeze dsl_attribute :types do |*types| if !types.empty? @types = types.flatten.map { |type| create_builtin_or_lookup_named_type(type) } else @types end end # Unions are serialized as an array of types def serialize(referenced_state) types.map { |type| type.serialize(referenced_state) } end # serialized will be an array of types. If the array includes # :null then it is moved to the beginning of the array. def self.union_with_null(serialized) serialized.reject { |type| type.to_s == NULL_TYPE }.unshift(:null) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
avro-builder-0.3.2 | lib/avro/builder/types/union_type.rb |