Sha256: 9d288ee7a7bf48a431c38e10f0d1fd6eedcd40ecf4e647d89e862c2b528a6909

Contents?: true

Size: 672 Bytes

Versions: 4

Compression:

Stored size: 672 Bytes

Contents

module Avro
  module Builder
    module Types

      # This module provides common functionality for Types with a specific
      # type name vs the generic Type class.
      module SpecificType

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

        # Override initialize so that type name is not required
        def initialize
        end

        def type_name
          self.class.type_name
        end

        module ClassMethods

          # Infer type_name based on class
          def type_name
            @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.3.1 lib/avro/builder/types/specific_type.rb
avro-builder-0.3.0 lib/avro/builder/types/specific_type.rb
avro-builder-0.2.0 lib/avro/builder/types/specific_type.rb
avro-builder-0.1.0 lib/avro/builder/types/specific_type.rb