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
Post a Comment