I'm trying to figure why this code:
class BaseClass
end
module Extensions
def self.included(base)
base.extend(ClassMethods)
end
module ClassMethods
def message(message)
@@message = message
end
end
end
BaseClass.send(:include, Extensions)
class ExtendedClass < BaseClass
message "hello world!"
def say_message
puts @@message
end
end
ExtendedClass.new.say_message
outputs:
test.rb:22:in `say_message': uninitialized class variable @@message in ExtendedClass (NameError)
from test.rb:26:in `<main>'
instead of
hello world!
Can you please explain me why?