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 429 def initialize(name, space, symbols, names=nil, doc=nil, default=nil, aliases=nil) 430 if symbols.uniq.length < symbols.length 431 fail_msg = "Duplicate symbol: #{symbols}" 432 raise Avro::SchemaParseError, fail_msg 433 end 434 435 if !Avro.disable_enum_symbol_validation 436 invalid_symbols = symbols.select { |symbol| symbol !~ SYMBOL_REGEX } 437 438 if invalid_symbols.any? 439 raise SchemaParseError, 440 "Invalid symbols for #{name}: #{invalid_symbols.join(', ')} don't match #{SYMBOL_REGEX.inspect}" 441 end 442 end 443 444 if default && !symbols.include?(default) 445 raise Avro::SchemaParseError, "Default '#{default}' is not a valid symbol for enum #{name}" 446 end 447 448 super(:enum, name, space, names, doc, nil, aliases) 449 @default = default 450 @symbols = symbols 451 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 453 def to_avro(_names=Set.new) 454 avro = super 455 if avro.is_a?(Hash) 456 avro['symbols'] = symbols 457 avro['default'] = default if default 458 end 459 avro 460 end