I have a ruby issue that I’m hoping someone can shed some light on. Its
probably not so much a Ruby issue as a dinosaur ex Cobol programmer
trying to work with objects rather than records.
I’m using Ruby to generate ConTeXt code to automate a report. One part
of the data is about tape libraries and looks something like this
I’m creating this data in part from an input file and in part from
stored database information, and the whole tree of objects is created
so that the Initialize of one object calls the initialize of the next
sub object as needed.
One of the attributes of Device is latest_ucode and it is looked up in
Now it turns out that the latest microcode level for a drive depends on
the type of the tape library as well as the type of the drive, so when
I’m down in the depths of of Initialize for the Device object I need to
access the tape library model several steps up the data structure.
The only way that I have been able to work around this is to pass Self
down into the creation of the next level object and use that to create
a @parent attribute, which I can then follow back up as necessary.
This feels kludgy and unsatisfying though and is not nearly general
enough for my taste.
Can someone please point me at the Ruby way to do this?