Sha256: 205e9d4c76bf7c9bbaf75bd44b1f3da9cb0cfa126bded35e6ca691dd9d7e5052
Contents?: true
Size: 1.41 KB
Versions: 2
Compression:
Stored size: 1.41 KB
Contents
require 'avro/builder/types/configurable_type' require 'avro/builder/namespaceable' module Avro module Builder module Types # This is an abstract class that represents a type that can be defined # with a name, outside a record. class NamedType < Type include Avro::Builder::Types::SpecificType include Avro::Builder::Namespaceable include Avro::Builder::Types::ConfigurableType dsl_attributes :name, :namespace, :aliases def generated_name name || "__#{field.name}_#{type_name}" end # As a type for a field # Subclasses may call super with additional overrides to be added # to the serialized value. def serialize(reference_state, overrides: {}) reference_state.definition_or_reference(fullname) do { name: generated_name, type: type_name, namespace: namespace }.merge(overrides).reject { |_, v| v.nil? } end end # As a top-level, named type # Subclasses may call super with additional overrides to be added # to the hash representation. def to_h(_reference_state, overrides: {}) { name: name, type: type_name, namespace: namespace, aliases: aliases }.merge(overrides).reject { |_, v| v.nil? } end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
avro-builder-0.2.0 | lib/avro/builder/types/named_type.rb |
avro-builder-0.1.0 | lib/avro/builder/types/named_type.rb |