module UsefulFeatures
def class_name
self.class.to_s
end
end
class Person
include UsefulFeatures
end
x = Person.new
p x.class_name
# if you want the method on Person too, you’ll
# have to extend
class Person
extend UsefulFeatures
end
# could have done this, too: Person.extend UsefulFeatures
p Person.class_name