Module: Avro::Builder::Types::ComplexType

Included in:
ArrayType, MapType, NamedType, UnionType
Defined in:
lib/avro/builder/types/complex_type.rb

Overview

This module provides common functionality for non-primitive types that do not require a name to be created.

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object


9
10
11
# File 'lib/avro/builder/types/complex_type.rb', line 9

def self.included(base)
  base.extend ClassMethods
end

Instance Method Details

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

Override initialize so that type name is not required


14
15
16
# File 'lib/avro/builder/types/complex_type.rb', line 14

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

#namespaceObject


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

def namespace
  field.namespace
end

#serialize(_reference_state, overrides: {}) ⇒ Object


22
23
24
25
26
27
# File 'lib/avro/builder/types/complex_type.rb', line 22

def serialize(_reference_state, overrides: {})
  {
    type: avro_type_name,
    logicalType: logical_type
  }.merge(overrides).reject { |_, v| v.nil? }
end

#to_h(reference_state) ⇒ Object


29
30
31
# File 'lib/avro/builder/types/complex_type.rb', line 29

def to_h(reference_state)
  serialize(reference_state)
end