I am trying to understand module inclusions with class variables. I thought that including a module with class variables would also include the class variables into the class definition.
This works as intended:
module A
@@my_name = "rick"
def print_name
puts @@my_name
end
end
class Y
include A
extend A
end
Y.print_name
But this does not:
module A
def self.included(klass)
klass.include B
klass.extend C
end
module B
@@my_name = "bob"
end
module C
def print_name
puts @@my_name
end
end
end
class Y
include A
end
Y.print_name
I was expecting "bob" but instead i got:
uninitialized class variable @@my_name in A::C