Class: Tros::Schema::EnumSchema
- Inherits:
-
NamedSchema
- Object
- Tros::Schema
- NamedSchema
- Tros::Schema::EnumSchema
- 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
-
#symbols ⇒ Object
readonly
Returns the value of attribute symbols.
Attributes inherited from NamedSchema
Attributes inherited from Tros::Schema
Instance Method Summary collapse
-
#initialize(name, space, symbols, names = nil) ⇒ EnumSchema
constructor
A new instance of EnumSchema.
- #to_avro(names = Set.new) ⇒ Object
Methods inherited from NamedSchema
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
#symbols ⇒ Object (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 |