Method: Avro::Schema::EnumSchema#initialize
- Defined in:
- lib/avro/schema.rb
#initialize(name, space, symbols, names = nil, doc = nil, default = nil, aliases = nil) ⇒ EnumSchema
Returns a new instance of EnumSchema.
429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 |
# File 'lib/avro/schema.rb', line 429 def initialize(name, space, symbols, names=nil, doc=nil, default=nil, aliases=nil) if symbols.uniq.length < symbols.length fail_msg = "Duplicate symbol: #{symbols}" raise Avro::SchemaParseError, fail_msg end if !Avro.disable_enum_symbol_validation invalid_symbols = symbols.select { |symbol| symbol !~ SYMBOL_REGEX } if invalid_symbols.any? raise SchemaParseError, "Invalid symbols for #{name}: #{invalid_symbols.join(', ')} don't match #{SYMBOL_REGEX.inspect}" end end if default && !symbols.include?(default) raise Avro::SchemaParseError, "Default '#{default}' is not a valid symbol for enum #{name}" end super(:enum, name, space, names, doc, nil, aliases) @default = default @symbols = symbols end |