Class: Deimos::AvroDataCoder

Inherits:
Object
  • Object
show all
Defined in:
lib/deimos/avro_data_coder.rb

Overview

Base class for the encoder / decoder classes.

Direct Known Subclasses

AvroDataDecoder, AvroDataEncoder

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(schema:, namespace:, schema_store: nil) ⇒ AvroDataCoder

Returns a new instance of AvroDataCoder.

Parameters:



11
12
13
14
15
16
# File 'lib/deimos/avro_data_coder.rb', line 11

def initialize(schema:, namespace:, schema_store: nil)
  @schema = schema
  @namespace = namespace
  @schema_store = schema_store ||
                  AvroTurf::SchemaStore.new(path: Deimos.config.schema_path)
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



6
7
8
# File 'lib/deimos/avro_data_coder.rb', line 6

def config
  @config
end

#namespaceObject

Returns the value of attribute namespace.



6
7
8
# File 'lib/deimos/avro_data_coder.rb', line 6

def namespace
  @namespace
end

#schemaObject

Returns the value of attribute schema.



6
7
8
# File 'lib/deimos/avro_data_coder.rb', line 6

def schema
  @schema
end

#schema_storeObject

Returns the value of attribute schema_store.



6
7
8
# File 'lib/deimos/avro_data_coder.rb', line 6

def schema_store
  @schema_store
end

Instance Method Details

#avro_schema(schema = nil) ⇒ Avro::Schema

Parameters:

  • schema (String) (defaults to: nil)

Returns:

  • (Avro::Schema)


20
21
22
23
# File 'lib/deimos/avro_data_coder.rb', line 20

def avro_schema(schema=nil)
  schema ||= @schema
  @schema_store.find(schema, @namespace)
end