Class: Avro::Schema::EnumSchema

Inherits:
NamedSchema show all
Defined in:
lib/avro/schema.rb

Constant Summary

Constants inherited from Avro::Schema

INT_MAX_VALUE, INT_MIN_VALUE, LONG_MAX_VALUE, LONG_MIN_VALUE, NAMED_TYPES, NAMED_TYPES_SYM, PRIMITIVE_TYPES, PRIMITIVE_TYPES_SYM, VALID_TYPES, VALID_TYPES_SYM

Instance Attribute Summary collapse

Attributes inherited from NamedSchema

#name, #namespace

Attributes inherited from Avro::Schema

#logical_type, #type_sym

Instance Method Summary collapse

Methods inherited from NamedSchema

#fullname

Methods inherited from Avro::Schema

#==, #be_read?, #hash, #md5_fingerprint, #mutual_read?, parse, #read?, real_parse, #sha256_fingerprint, #subparse, #to_s, #type, #type_adapter, validate

Constructor Details

#initialize(name, space, symbols, names = nil) ⇒ EnumSchema

Returns a new instance of EnumSchema.



309
310
311
312
313
314
315
316
# File 'lib/avro/schema.rb', line 309

def initialize(name, space, symbols, names=nil)
  if symbols.uniq.length < symbols.length
    fail_msg = 'Duplicate symbol: %s' % symbols
    raise Avro::SchemaParseError, fail_msg
  end
  super(:enum, name, space, names)
  @symbols = symbols
end

Instance Attribute Details

#symbolsObject (readonly)

Returns the value of attribute symbols.



308
309
310
# File 'lib/avro/schema.rb', line 308

def symbols
  @symbols
end

Instance Method Details

#to_avro(names = Set.new) ⇒ Object



318
319
320
321
# File 'lib/avro/schema.rb', line 318

def to_avro(names=Set.new)
  avro = super
  avro.is_a?(Hash) ? avro.merge('symbols' => symbols) : avro
end