ruby - How do I access the string name of the parent class from a class method in a extended class or included module -
My problem basically looks like this:
module fu square bar DRF itself . Which is itself called .class.to_s End End and World World & lt; Foo :: Bar end When I call World.who "World" As a result, I get it "Class" . Some Quick Googling has not got anything useful, so I'm hoping someone would know how to get the right class names :)
If you are calling foo.bar , the value of manually inside the bar method < Code> will be> foo . So when you call World.who inside self which is is World . Since world is a class, world.class will be back to class , so that's what you get.
To get back, call self.to_s or self.name (or just < Code> to_s or name ).
Comments
Post a Comment