Here is my module that is trying to set the instance variable. I try to initialize and enable self.included, but none of them work when I do include in the outermost area ( main):
module Asd
def initialize
@asd = 0
end
def self.included(base)
@asd = 0
end
attr_reader :asd
end
Including this in the class works, and I can read the instance variable:
class Bsd
include Asd
end
Bsd.new.asd
But doing this globally does not work:
include Asd
@asd
asd
I often know that people will question the motivation to host their code globally. In this case, I just want to see how this is done.
source
share