Class: Avro::Schema::PrimitiveSchema
- Inherits:
-
Avro::Schema
- Object
- Avro::Schema
- Avro::Schema::PrimitiveSchema
- Defined in:
- lib/avro/schema.rb
Overview
Valid primitive types are in PRIMITIVE_TYPES.
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
Attributes inherited from Avro::Schema
Instance Method Summary collapse
-
#initialize(type, logical_type = nil) ⇒ PrimitiveSchema
constructor
A new instance of PrimitiveSchema.
- #to_avro(names = nil) ⇒ Object
Methods inherited from Avro::Schema
#==, #hash, #md5_fingerprint, parse, real_parse, #sha256_fingerprint, #subparse, #to_s, #type, #type_adapter, validate
Constructor Details
#initialize(type, logical_type = nil) ⇒ PrimitiveSchema
Returns a new instance of PrimitiveSchema.
347 348 349 350 351 352 353 354 355 |
# File 'lib/avro/schema.rb', line 347 def initialize(type, logical_type=nil) if PRIMITIVE_TYPES_SYM.include?(type) super(type, logical_type) elsif PRIMITIVE_TYPES.include?(type) super(type.to_sym, logical_type) else raise AvroError.new("#{type} is not a valid primitive type.") end end |
Instance Method Details
#to_avro(names = nil) ⇒ Object
357 358 359 360 |
# File 'lib/avro/schema.rb', line 357 def to_avro(names=nil) hsh = super hsh.size == 1 ? type : hsh end |