Alexandre Calvão
2014-Oct-10 03:17 UTC
Get the class name of the class who called the parent instance method.
Is there a way for me to do that on ruby ?
class Foo
def self.class_name
self.class.name
end
end
class Bar < Foo
end
class Tar < Foo
end
Bar.class_name
= 'Bar'
Tar.class_name
= 'Tar'
I want to get the class name of the class who called the instance method
from the parent class.
I tried the code above and it keeps getting me 'Class' as the result.
Is that possible in ruby ?
[]`s
==================*Alexandre Mondaini Calvão*
"*Nossa recompensa se encontra no esforço e não no resultado. Um esforço
total é uma vitória completa*." [Ghandi]
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit
https://groups.google.com/d/msgid/rubyonrails-talk/CA%2BaBw4TbFZO%2BBE0DvYJ93ctCq1gMkWaNQS9tr6W5yok4tPw34A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.