public Method

Dependencies.to_constant_name(desc)

Convert the provided const desc to a qualified constant name (as a string). A module, class, symbol, or string may be provided.

Source Code

# File active_support/dependencies.rb, line 397
def to_constant_name(desc) #:nodoc:
  name = case desc
    when String then desc.starts_with?('::') ? desc[2..-1] : desc
    when Symbol then desc.to_s
    when Module
      raise ArgumentError, "Anonymous modules have no name to be referenced by" if desc.name.blank?
      desc.name
    else raise TypeError, "Not a valid constant descriptor: #{desc.inspect}"
  end
end
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.