class Tros::Schema::UnionSchema

Attributes

schemas[R]

Public Class Methods

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

Public Instance Methods

to_avro(names=Set.new) click to toggle source
    # File lib/tros/schema.rb
304 def to_avro(names=Set.new)
305   schemas.map {|schema| schema.to_avro(names) }
306 end