class Foo attr_accessor :bar end
Foo.new.bar = 1
class Person class << self attr_accessor :name end end
Person.name = "Luke"
Let's say we want to have this happen automatically when we include a module. In the following example, as klass is equal to self in the declaration above "class << self", we can apply the same technique we used above.
module Age def self.included(klass) class << klass attr_accessor :age end end end
Person.age = "old enough to know better"