module Octiron::Support::Identifiers

@see Identifiers::identify

Public Instance Methods

identify(name) click to toggle source

This function “identifies” an object, i.e. returns a unique ID according to the octiron logic. That means that:

  • For classes, a stringified version is returned

  • For hashes, the hash itself is returned

  • Strings are interpreted as constant names, and are returned fully qualified.

  • Everything else is considered to be a constant name in the default namespace. This requires access to a @default_namespace variable in the including class.

# File lib/octiron/support/identifiers.rb, line 30
def identify(name)
  case name
  when Class
    return name.to_s
  when Hash
    return name
  when String
    return constantize(name).to_s
  when nil
    raise NameError, "Can't identify 'nil'!"
  else
    return constantize("#{@default_namespace}::#{camel_case(name)}").to_s
  end
end