ruby on rails - Get name of subclass -


lets have class called

a = person::user::base 

how can last subclass called base.

the way know how is:

a.to_s.split('::').last  => "base"  

is there better way?

if use rails (activesupport):

a.to_s.demodulize

if use por (plain-ol-ruby), yes, it's way:

a.to_s.split('::').last


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -