I'm somewhat new to ruby, only being called upon to maintain some old, undocumented code here and there. I have a base class in ruby where I put a hash class variable.
@@projects = Hash.new
And I want my derived classes to add to it via a method (passing in a parameter). The problem is, it seems like each derived class has its own copy of the hash, instead of accessing a single 'static' version of it.
Could someone help?
class Base
@@projects = Hash.new
def AddSomething key, value
@@projects[key] = value
end
end
class Derived < Base
def initialize
...
AddSomething key, value
...
end
end
So, in the code sample above, every time I add a value to @@projects in the AddSomething function the size/length of the hash is always 1, it never grows. It acts as if it's an instance variable which is not what I want.
Any ideas? I'm stumped here.