Class: Avro::Builder::Types::ComplexType

Inherits:
Type
  • Object
show all
Defined in:
lib/avro/builder/types/complex_type.rb

Overview

This is an abstract class that provides common functionality for non-primitive types that do not require a name to be created.

Direct Known Subclasses

ArrayType, MapType, NamedType, UnionType

Constant Summary

Constants included from DslAttributes

DslAttributes::ATTRIBUTE_NAMES

Instance Attribute Summary

Attributes inherited from Type

#avro_type_name

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Type

#abstract?, #cache!, #configure_options, #dsl_method?, #dsl_respond_to?, #serialize, #to_h, union_with_null, #validate!

Methods included from Metadata

attribute?, #method_missing, register, reset!, #respond_to_missing?

Methods included from DslAttributes

#dsl_attribute?, included

Methods included from DslOptions

#dsl_option?, included

Constructor Details

#initialize(cache:, field: nil) ⇒ ComplexType

Override initialize so that type name is not required



17
18
19
# File 'lib/avro/builder/types/complex_type.rb', line 17

def initialize(cache:, field: nil)
  super(self.class.avro_type_name, cache: cache, field: field)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Avro::Builder::Metadata

Class Method Details

.avro_type_name ⇒ Object

Infer avro_type_name based on class



12
13
14
# File 'lib/avro/builder/types/complex_type.rb', line 12

def self.avro_type_name
  @avro_type_name ||= name.split('::').last.sub('Type', '').downcase.to_sym
end

Instance Method Details

#namespace ⇒ Object



21
22
23
# File 'lib/avro/builder/types/complex_type.rb', line 21

def namespace
  field.namespace
end