How I can get from a module the Class name of the class the module is included ?
module ActMethods
def some_method(*attr_names)
cls = self.class # this doesn't work
end
end
How I can get into the cls variable the name of the class to with this module is loaded ?
self.classdoes get you the class of the object the method is called on. Assuming the module was included into a class, this either is the class that included the module or a subclass thereof. If you really just want the name, you can useself.class.nameinstead.If you extended a class with the module and you want to get that class, you can just do
cls = self(orcls = nameif you want the name of the class as a string).If none of the above helps, you should clarify what you want.