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 400 def initialize(schemas, names=nil, default_namespace=nil) 401 super(:union) 402 403 @schemas = schemas.each_with_object([]) do |schema, schema_objects| 404 new_schema = subparse(schema, names, default_namespace) 405 ns_type = new_schema.type_sym 406 407 if VALID_TYPES_SYM.include?(ns_type) && 408 !NAMED_TYPES_SYM.include?(ns_type) && 409 schema_objects.any?{|o| o.type_sym == ns_type } 410 raise SchemaParseError, "#{ns_type} is already in Union" 411 elsif ns_type == :union 412 raise SchemaParseError, "Unions cannot contain other unions" 413 else 414 schema_objects << new_schema 415 end 416 end 417 end
Public Instance Methods
to_avro(names=Set.new)
click to toggle source
# File lib/avro/schema.rb 419 def to_avro(names=Set.new) 420 schemas.map {|schema| schema.to_avro(names) } 421 end