module Module1
class Base1
class << self
attr_accessor :attr1, :attr2
def configure
yield(self) if block_given?
end
end
end
end
module Module1
class Child1 < Base1
def self.some_method1
#... some stuff
"#{attr1}_123" #for some reason attr1 is nil
end
end
end
Module1::Base1.configure do |item|
item.method1 = "43243243"
item.method2 = "fdsfdsfd"
end
data1 = Module1::Child1.some_method1 #it doesn't return what I expect
何らかの理由 attr1
で、inは値がある場所とChild1#some_method1
はnil
異なりModule1::Base1.method1
ます。それを取り除くためになぜそして何をすべきか疑問に思いますか?