Class: Tros::Schema::Field
- Inherits:
-
Tros::Schema
- Object
- Tros::Schema
- Tros::Schema::Field
- 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
-
#default ⇒ Object
readonly
Returns the value of attribute default.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#order ⇒ Object
readonly
Returns the value of attribute order.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Attributes inherited from Tros::Schema
Instance Method Summary collapse
-
#initialize(type, name, default = nil, order = nil, names = nil, namespace = nil) ⇒ Field
constructor
A new instance of Field.
- #to_avro(names = Set.new) ⇒ Object
Methods inherited from Tros::Schema
#==, #hash, parse, real_parse, #subparse, #to_s, validate, validate_strictly
Constructor Details
#initialize(type, name, default = nil, order = nil, names = nil, namespace = nil) ⇒ Field
Returns a new instance of Field.
362 363 364 365 366 367 |
# File 'lib/tros/schema.rb', line 362 def initialize(type, name, default=nil, order=nil, names=nil, namespace=nil) @type = subparse(type, names, namespace) @name = name @default = default @order = order end |
Instance Attribute Details
#default ⇒ Object (readonly)
Returns the value of attribute default.
360 361 362 |
# File 'lib/tros/schema.rb', line 360 def default @default end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
360 361 362 |
# File 'lib/tros/schema.rb', line 360 def name @name end |
#order ⇒ Object (readonly)
Returns the value of attribute order.
360 361 362 |
# File 'lib/tros/schema.rb', line 360 def order @order end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
360 361 362 |
# File 'lib/tros/schema.rb', line 360 def type @type end |
Instance Method Details
#to_avro(names = Set.new) ⇒ Object
369 370 371 372 373 374 |
# File 'lib/tros/schema.rb', line 369 def to_avro(names=Set.new) {'name' => name, 'type' => type.to_avro(names)}.tap do |tros| tros['default'] = default if default tros['order'] = order if order end end |