Module: Tros::Name
- Defined in:
- lib/tros/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).
390 391 392 393 394 395 396 397 398 399 400 401 402 |
# File 'lib/tros/schema.rb', line 390 def self.add_name(names, new_schema) new_fullname = new_schema.fullname if Tros::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
381 382 383 384 385 386 387 |
# File 'lib/tros/schema.rb', line 381 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
404 405 406 407 408 409 410 |
# File 'lib/tros/schema.rb', line 404 def self.make_fullname(name, namespace) if !name.include?('.') && !namespace.nil? namespace + '.' + name else name end end |