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

javascript - three.js lot of meshes optimization -

smartface.io - Proper way to change color scheme for whole application -

Email notification in google apps script -