Module: Avro::Name
- Defined in:
- lib/avro/schema.rb
Class Method Summary collapse
-
.add_name(names, new_schema) ⇒ Object
Add a new schema object to the names dictionary (in place).
- .extract_namespace(name, namespace) ⇒ Object
- .make_fullname(name, namespace) ⇒ Object
Class Method Details
.add_name(names, new_schema) ⇒ Object
Add a new schema object to the names dictionary (in place).
420 421 422 423 424 425 426 427 428 429 430 431 432 |
# File 'lib/avro/schema.rb', line 420 def self.add_name(names, new_schema) new_fullname = new_schema.fullname if Avro::Schema::VALID_TYPES.include?(new_fullname) raise SchemaParseError, "#{new_fullname} is a reserved type name." elsif names.nil? names = {} elsif names.has_key?(new_fullname) raise SchemaParseError, "The name \"#{new_fullname}\" is already in use." end names[new_fullname] = new_schema names end |
.extract_namespace(name, namespace) ⇒ Object
411 412 413 414 415 416 417 |
# File 'lib/avro/schema.rb', line 411 def self.extract_namespace(name, namespace) parts = name.split('.') if parts.size > 1 namespace, name = parts[0..-2].join('.'), parts.last end return name, namespace end |
.make_fullname(name, namespace) ⇒ Object
434 435 436 437 438 439 440 |
# File 'lib/avro/schema.rb', line 434 def self.make_fullname(name, namespace) if !name.include?('.') && !namespace.nil? namespace + '.' + name else name end end |