I have two files: one with the ToMix module:
module ToMix @module_var = "modulevar" def self.mix_function puts "mix_function SELF: #{@module_var}" end def mix_function puts "mix_function: #{@module_var}" end class MixClass attr_accessor :mixclassvar def initialize(value) @mixclassvar = value end end end
which I want to mix with the TestInclude class in another file:
class TestInclude require "ToMixFile" include ToMix end
Can anyone explain why the @module_var instance @module_var and the self.mix_function , mix_function are undefined? And how would I define them?
t2 = TestInclude.new() t2.mix_function # => error undefined (exected call to mix_function) t2.module_var = "test set module_var" # => error undefined TestInclude.mix_function # => error undefined (expected call to self.mix_function) TestInclude.method_defined? :mix_function # => false
source share