Sha256: 59477f26f1749f1cca2bbc2b27d0ab681ce5e3f0d71820f60727a41950a1b73b

Contents?: true

Size: 1.01 KB

Versions: 7

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

module Avro
  module Builder

    # This concern is included by contexts where anonymous types can be defined.
    module AnonymousTypes
      include Avro::Builder::TypeFactory

      Avro::Schema::PRIMITIVE_TYPES_SYM.each do |type_name|
        define_method(type_name) do |options = {}, &block|
          type(type_name, options, &block)
        end
      end

      def union(*types, &block)
        type(__method__, { types: types }, &block)
      end

      def array(items, options = {}, &block)
        type(__method__, { items: items }.merge(options), &block)
      end

      def map(values, options = {}, &block)
        type(__method__, { values: values }.merge(options), &block)
      end

      def type(type_name, options = {}, &block)
        create_and_configure_builtin_type(type_name,
                                          cache: cache,
                                          internal: options,
                                          &block)
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
avro-builder-2.1.0 lib/avro/builder/anonymous_types.rb
avro-builder-2.0.0 lib/avro/builder/anonymous_types.rb
avro-builder-1.1.0 lib/avro/builder/anonymous_types.rb
avro-builder-1.0.1 lib/avro/builder/anonymous_types.rb
avro-builder-1.0.0 lib/avro/builder/anonymous_types.rb
avro-builder-0.17.0 lib/avro/builder/anonymous_types.rb
avro-builder-0.16.2 lib/avro/builder/anonymous_types.rb