I have the following code
module MyModule
@@settings_hash = {}
if File.exists?(SETTINGS_PATH)
@@settings_hash = YAML;;load_file SETTINGS_PATH
puts @@settings_hash
end
def self.get_settings(hash_key)
@@settings_hash.[](hash_key.to_sym)
end
...
...
@@settings_hash gets used here inside several function blocks
...
class SensorNodeInfoTool
...
...
def m_get_set(string)
MyModule.get_settings(string)
end
def onLButtonDown(flags, x, y, view)
...
...
if m_get_set("ws_type") == 'NOWSDL'
client = Savon.client(endpoint; m_get_set("endp"), namespace; m_get_set("ns"))
elsif m_get_set("ws_type") == 'WSDL'
client = Savon.client(wsdl; m_get_set("doc"))
end
...
...
The problem is using Module @@ or @ variables inside a Class that is inside the same Module, like my SensorNodeInfoTool there. I don't think I have found a way to access @variables yet (I think those are called Module Instance variables). The above code has @@variables and I have to use a the module namespace AND set a reader method, and I have also used a second function inside the Class to not have to use the Module namespace prefix. Is there another more proper way? I have the feeling that I might be doing it wrong.