Thanks brian - I had guessed that this was a potential issue. I'll try to dig deeper to the root problem.
I have this gem I have been kicking around for some time, found
here. The intent was to create a series of tools to help people making Tabletop RPG programs (though, realistically, it is a way to hone my skills in my free time).
My intention was to make it so that the person using the gem would have to re-write as little as possible. I have a class, Game, that contains several methods that return certain truths about the game at hand - so, self.dice_sides = 6 (the number of sides in a die used to generate the character), or stats (an array of the stats used in the game). this is referenced elsewhere, accordingly, as Game.stats, Game.dice_sides, etc. This is useful because - even as I transition away from including serious logic in the gem - the StatList class is always going to want a list of attr_accessors that is equal to the stats of the game, and it would be better to have the eventual user change one line rather than changing every instance of "Game" to the new class manually.
When making new versions of games, I realized that simply overwriting these values was tricky; two games couldn't exist in the same database down the road, for example, because they would have different values for Game.dice_sides. The initial solution was to alias; if i had to overwrite something, it would be under this aliased name in lieu of 'Game' (so, Dnd.dice_sides) and I could re-write the Game class wholeheartedly with these new values... which brings me back to the same problem (if they are aliased, I am not sure it fixes the issue at hand.)
My initial thought was to use "game" as a superclass (containing all the other classes) and then have the end user extend "Game" to "Pathfinder" or "DnD", and then overwriting those values as they will. I already tried to do this with Constants, but it appears to not work either.
So, perhaps the root of my question: Is there something that will last within the scope of a class that can be referenced by nested classes that I can re-write when I extend the class?
In psuedocode:
class A
(magic) = 6
class B
def b (b = (magic) )
puts (magic)
end
end
class A2 < A
(magic) =40
end
A2::B.b
40
(I understand that I just incorrectly used the 'nested classes' syntax again incorrectly, but it was the only way I knew how to get the idea across. Being told "This is a fruitless path to continue to tread" is useful advice as well, if there isn't a simple or good way to do this.)
---------------------------
Alex M. Jarvis
www.AlxJrvs.com'AlxJrvs' on Twitter