class Avro::Schema::UnionSchema
Attributes
schemas[R]
Public Class Methods
new(schemas, names=nil, default_namespace=nil)
click to toggle source
Calls superclass method
Avro::Schema::new
# File lib/avro/schema.rb 283 def initialize(schemas, names=nil, default_namespace=nil) 284 super(:union) 285 286 @schemas = schemas.each_with_object([]) do |schema, schema_objects| 287 new_schema = subparse(schema, names, default_namespace) 288 ns_type = new_schema.type_sym 289 290 if VALID_TYPES_SYM.include?(ns_type) && 291 !NAMED_TYPES_SYM.include?(ns_type) && 292 schema_objects.any?{|o| o.type_sym == ns_type } 293 raise SchemaParseError, "#{ns_type} is already in Union" 294 elsif ns_type == :union 295 raise SchemaParseError, "Unions cannot contain other unions" 296 else 297 schema_objects << new_schema 298 end 299 end 300 end
Public Instance Methods
to_avro(names=Set.new)
click to toggle source
# File lib/avro/schema.rb 302 def to_avro(names=Set.new) 303 schemas.map {|schema| schema.to_avro(names) } 304 end