Class: Tros::Schema::EnumSchema

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

Constant Summary

Constants inherited from Tros::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 Tros::Schema

#type_sym

Instance Method Summary collapse

Methods inherited from NamedSchema

#fullname

Methods inherited from Tros::Schema

#==, #hash, parse, real_parse, #subparse, #to_s, #type, validate, validate_strictly

Constructor Details

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

Returns a new instance of EnumSchema.



311
312
313
314
315
316
317
318
# File 'lib/tros/schema.rb', line 311

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

Instance Attribute Details

#symbolsObject (readonly)

Returns the value of attribute symbols.



310
311
312
# File 'lib/tros/schema.rb', line 310

def symbols
  @symbols
end

Instance Method Details

#to_avro(names = Set.new) ⇒ Object



320
321
322
323
# File 'lib/tros/schema.rb', line 320

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