I am using Ruby on Rails 3.0.7 and I would like to retrieve the class name, also if it is namespaced. For example, if I have a class named User::Profile::Manager
I would retrieve the Manager
string from that using some unknown to me Ruby or Ruby on Rails method and in a secure way.
BTW: What other "usefull" information that are "commonly" used can I get for the class?
Some useful simple metaprogramming calls:
If you want the lowest-level class from
User::Profile::Manager
I'd probably do the following [using a regex for this seems like overkill to me ;)]:Edit:
If you actually want to look through some more metaprogramming calls, check the docs for the Object and Module classes, and check out the google results for "Ruby Metaprogramming".
To expand on @JCorcuera's answer, some other useful information can be found with kind_of? and methods
Have you tried
class
method: