Class: Avromatic::Model::CustomTypeConfiguration

Inherits:
Object
  • Object
show all
Defined in:
lib/avromatic/model/custom_type_configuration.rb

Overview

Instances of this class contains the configuration for custom handling of a named type (record, enum, fixed).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value_class) ⇒ CustomTypeConfiguration

Returns a new instance of CustomTypeConfiguration.



12
13
14
# File 'lib/avromatic/model/custom_type_configuration.rb', line 12

def initialize(value_class)
  @value_class = value_class
end

Instance Attribute Details

#from_avroObject

Returns the value of attribute from_avro.



10
11
12
# File 'lib/avromatic/model/custom_type_configuration.rb', line 10

def from_avro
  @from_avro
end

#to_avroObject

Returns the value of attribute to_avro.



10
11
12
# File 'lib/avromatic/model/custom_type_configuration.rb', line 10

def to_avro
  @to_avro
end

#value_classObject

Returns the value of attribute value_class.



10
11
12
# File 'lib/avromatic/model/custom_type_configuration.rb', line 10

def value_class
  @value_class
end

Instance Method Details

#deserializerObject

A deserializer method is used when assigning to the model. It is used both when deserializing a model instance from Avro and when directly instantiating an instance. The deserializer method must accept a single argument and return the value to store in the model for the attribute.



20
21
22
23
# File 'lib/avromatic/model/custom_type_configuration.rb', line 20

def deserializer
  proc = from_avro_proc
  wrap_proc(proc) if proc
end

#serializerObject

A serializer method is used when preparing attributes to be serialized using Avro. The serializer method must accept a single argument of the model value for the attribute and return a value in a form that Avro can serialize for the attribute.



29
30
31
32
# File 'lib/avromatic/model/custom_type_configuration.rb', line 29

def serializer
  proc = to_avro_proc
  wrap_proc(proc) if proc
end