class Avro::Schema::EnumSchema
Constants
- SYMBOL_REGEX
Attributes
default[R]
doc[R]
symbols[R]
Public Class Methods
new(name, space, symbols, names=nil, doc=nil, default=nil, aliases=nil)
click to toggle source
Calls superclass method
Avro::Schema::NamedSchema::new
# File lib/avro/schema.rb 430 def initialize(name, space, symbols, names=nil, doc=nil, default=nil, aliases=nil) 431 if symbols.uniq.length < symbols.length 432 fail_msg = "Duplicate symbol: #{symbols}" 433 raise Avro::SchemaParseError, fail_msg 434 end 435 436 if !Avro.disable_enum_symbol_validation 437 invalid_symbols = symbols.select { |symbol| symbol !~ SYMBOL_REGEX } 438 439 if invalid_symbols.any? 440 raise SchemaParseError, 441 "Invalid symbols for #{name}: #{invalid_symbols.join(', ')} don't match #{SYMBOL_REGEX.inspect}" 442 end 443 end 444 445 if default && !symbols.include?(default) 446 raise Avro::SchemaParseError, "Default '#{default}' is not a valid symbol for enum #{name}" 447 end 448 449 super(:enum, name, space, names, doc, nil, aliases) 450 @default = default 451 @symbols = symbols 452 end
Public Instance Methods
to_avro(_names=Set.new)
click to toggle source
Calls superclass method
Avro::Schema::NamedSchema#to_avro
# File lib/avro/schema.rb 454 def to_avro(_names=Set.new) 455 avro = super 456 if avro.is_a?(Hash) 457 avro['symbols'] = symbols 458 avro['default'] = default if default 459 end 460 avro 461 end