Module: Avro::LogicalTypes

Defined in:
lib/avro/logical_types.rb

Defined Under Namespace

Modules: Identity, IntDate, TimestampMicros, TimestampMillis, TimestampNanos Classes: BytesDecimal, LogicalTypeWithSchema

Constant Summary collapse

TYPES =
{
  "bytes" => {
    "decimal" => BytesDecimal
  },
  "int" => {
    "date" => IntDate
  },
  "long" => {
    "timestamp-millis" => TimestampMillis,
    "timestamp-micros" => TimestampMicros,
    "timestamp-nanos"  => TimestampNanos
  },
}.freeze

Class Method Summary collapse

Class Method Details

.type_adapter(type, logical_type, schema = nil) ⇒ Object



288
289
290
291
292
293
# File 'lib/avro/logical_types.rb', line 288

def self.type_adapter(type, logical_type, schema = nil)
  return unless logical_type

  adapter = TYPES.fetch(type, {}.freeze).fetch(logical_type, Identity)
  adapter.is_a?(Class) ? adapter.new(schema) : adapter
end