Sha256: 17e64171c9d5b1a47539354af8e67b6d6c3903b24adca2b64dd6e9db4091cc56

Contents?: true

Size: 723 Bytes

Versions: 3

Compression:

Stored size: 723 Bytes

Contents

# frozen_string_literal: true

module Avro
  module Builder
    module Types
      # Subclass for the primitive Bytes type because it supports the decimal logical type.
      class BytesType < Type
        dsl_attributes :precision, :scale

        def initialize(cache:, field: nil)
          super('bytes', field: field, cache: cache)
        end

        def serialize(reference_state)
          super(reference_state, overrides: serialized_attributes)
        end

        def to_h(reference_state)
          super(reference_state, overrides: serialized_attributes)
        end

        private

        def serialized_attributes
          { precision: precision, scale: scale }
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
avro-builder-2.1.0 lib/avro/builder/types/bytes_type.rb
avro-builder-2.0.0 lib/avro/builder/types/bytes_type.rb
avro-builder-1.1.0 lib/avro/builder/types/bytes_type.rb