Sha256: ddec6e5c7689e9fd1c6c2218b4ce95894e12454cd83c2e64b5c7418134df48d8

Contents?: true

Size: 999 Bytes

Versions: 9

Compression:

Stored size: 999 Bytes

Contents

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

9 entries across 9 versions & 1 rubygems

Version Path
avro-builder-0.16.1 lib/avro/builder/anonymous_types.rb
avro-builder-0.16.0 lib/avro/builder/anonymous_types.rb
avro-builder-0.15.0 lib/avro/builder/anonymous_types.rb
avro-builder-0.15.0.rc0 lib/avro/builder/anonymous_types.rb
avro-builder-0.14.1 lib/avro/builder/anonymous_types.rb
avro-builder-0.14.0 lib/avro/builder/anonymous_types.rb
avro-builder-0.13.0 lib/avro/builder/anonymous_types.rb
avro-builder-0.12.0 lib/avro/builder/anonymous_types.rb
avro-builder-0.11.0 lib/avro/builder/anonymous_types.rb