Sha256: 9cced8d302aeeb2585051146d3b10f82128b01bb02ab5dc1e3ce8ee42c7aac94

Contents?: true

Size: 729 Bytes

Versions: 5

Compression:

Stored size: 729 Bytes

Contents

module Avro
  module Builder
    module Types
      class EnumType < NamedType

        dsl_attribute :doc

        dsl_attribute :symbols do |*values|
          # Define symbols explicitly to support values as a splat or single array
          if !values.empty?
            @symbols = values.flatten
          else
            @symbols
          end
        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
          { symbols: symbols, doc: doc }
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
avro-builder-0.3.2 lib/avro/builder/types/enum_type.rb
avro-builder-0.3.1 lib/avro/builder/types/enum_type.rb
avro-builder-0.3.0 lib/avro/builder/types/enum_type.rb
avro-builder-0.2.0 lib/avro/builder/types/enum_type.rb
avro-builder-0.1.0 lib/avro/builder/types/enum_type.rb