Sha256: d927ade558b39761c92c59d07802ff8bab032d30ebfa266d467ba483bf380c14

Contents?: true

Size: 829 Bytes

Versions: 16

Compression:

Stored size: 829 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

        def validate!
          super
          validate_required_attribute!(:symbols)
        end

        private

        def serialized_attributes
          { symbols: symbols, doc: doc }
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
avro-builder-0.16.1 lib/avro/builder/types/enum_type.rb
avro-builder-0.16.0 lib/avro/builder/types/enum_type.rb
avro-builder-0.15.0 lib/avro/builder/types/enum_type.rb
avro-builder-0.15.0.rc0 lib/avro/builder/types/enum_type.rb
avro-builder-0.14.1 lib/avro/builder/types/enum_type.rb
avro-builder-0.14.0 lib/avro/builder/types/enum_type.rb
avro-builder-0.13.0 lib/avro/builder/types/enum_type.rb
avro-builder-0.12.0 lib/avro/builder/types/enum_type.rb
avro-builder-0.11.0 lib/avro/builder/types/enum_type.rb
avro-builder-0.10.0 lib/avro/builder/types/enum_type.rb
avro-builder-0.9.0 lib/avro/builder/types/enum_type.rb
avro-builder-0.8.0 lib/avro/builder/types/enum_type.rb
avro-builder-0.7.0 lib/avro/builder/types/enum_type.rb
avro-builder-0.6.0 lib/avro/builder/types/enum_type.rb
avro-builder-0.5.0 lib/avro/builder/types/enum_type.rb
avro-builder-0.4.0 lib/avro/builder/types/enum_type.rb