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).
394 395 396 397 398 399 400 401 402 403 404 405 406 |
# File 'lib/tros/schema.rb', line 394 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
385 386 387 388 389 390 391 |
# File 'lib/tros/schema.rb', line 385 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
408 409 410 411 412 413 414 |
# File 'lib/tros/schema.rb', line 408 def self.make_fullname(name, namespace) if !name.include?('.') && !namespace.nil? namespace + '.' + name else name end end |