Sha256: 98afd7619b71c9ad384b1010f2d0eb10270463e4b8c6040e9088acf6cfccaf6b

Contents?: true

Size: 775 Bytes

Versions: 4

Compression:

Stored size: 775 Bytes

Contents

module Avro
  module Builder
    module Types

      # This module provides common functionality for non-primitive types
      # that do not require a name to be created.
      module ComplexType

        def self.included(base)
          base.extend ClassMethods
        end

        # Override initialize so that type name is not required
        def initialize(cache:, field: nil)
          super(self.class.avro_type_name, cache: cache, field: field)
        end

        def namespace
          field.namespace
        end

        module ClassMethods

          # Infer avro_type_name based on class
          def avro_type_name
            @avro_type_name ||= name.split('::').last.sub('Type', '').downcase.to_sym
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
avro-builder-0.10.0 lib/avro/builder/types/complex_type.rb
avro-builder-0.9.0 lib/avro/builder/types/complex_type.rb
avro-builder-0.8.0 lib/avro/builder/types/complex_type.rb
avro-builder-0.7.0 lib/avro/builder/types/complex_type.rb