Class: Avro::Schema::NamedSchema

Inherits:
Avro::Schema show all
Defined in:
lib/avro/schema.rb

Direct Known Subclasses

EnumSchema, FixedSchema, RecordSchema

Constant Summary

Constants inherited from Avro::Schema

INT_MAX_VALUE, INT_MIN_VALUE, LONG_MAX_VALUE, LONG_MIN_VALUE, NAMED_TYPES, NAMED_TYPES_SYM, PRIMITIVE_TYPES, PRIMITIVE_TYPES_SYM, VALID_TYPES, VALID_TYPES_SYM

Instance Attribute Summary collapse

Attributes inherited from Avro::Schema

#logical_type, #type_sym

Instance Method Summary collapse

Methods inherited from Avro::Schema

#==, #be_read?, #hash, #md5_fingerprint, #mutual_read?, parse, #read?, real_parse, #sha256_fingerprint, #subparse, #to_s, #type, #type_adapter, validate

Constructor Details

#initialize(type, name, namespace = nil, names = nil, logical_type = nil) ⇒ NamedSchema

Returns a new instance of NamedSchema.



178
179
180
181
182
# File 'lib/avro/schema.rb', line 178

def initialize(type, name, namespace=nil, names=nil, logical_type=nil)
  super(type, logical_type)
  @name, @namespace = Name.extract_namespace(name, namespace)
  names = Name.add_name(names, self)
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



177
178
179
# File 'lib/avro/schema.rb', line 177

def name
  @name
end

#namespaceObject (readonly)

Returns the value of attribute namespace.



177
178
179
# File 'lib/avro/schema.rb', line 177

def namespace
  @namespace
end

Instance Method Details

#fullnameObject



194
195
196
# File 'lib/avro/schema.rb', line 194

def fullname
  @fullname ||= Name.make_fullname(@name, @namespace)
end

#to_avro(names = Set.new) ⇒ Object



184
185
186
187
188
189
190
191
192
# File 'lib/avro/schema.rb', line 184

def to_avro(names=Set.new)
  if @name
    return fullname if names.include?(fullname)
    names << fullname
  end
  props = {'name' => @name}
  props.merge!('namespace' => @namespace) if @namespace
  super.merge props
end