--------------020907030505000308020306
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
(Sorry for the long delay - I first had to find my old code and polish it a bit
before posting.)
I implemented something like a Codd relation a couple of months ago. It is no
persistence framework and it knows nothing about SQL. It's just a way to
structure your classes like you'd do in a relational db.
Here is the example Curt described in his original mail using my Relation module:
def test_journals
# Define the classes journal, volume, and article using a common base class.
named_object truct.new :name
def named_object.create *names
names.map { |name| new name }
end
journal lass.new named_object
volume lass.new named_object
article lass.new named_object
# Define the relations between the classes and the names of the accessor
# methods (read as "a journal consists of many volumes and a volume belongs
# to one journal").
Relation.new journal, :many, :volumes, volume, :one, :journal
Relation.new volume, :many, :articles, article, :many, :volumes
# Create some instances of the classes.
j1, j2 ournal.create "j1", "j2"
v11, v12, v21 olume.create "v11", "v12", "v21"
a1, a2, a3 rticle.create "a1", "a2", "a3"
# Connect the instances. You can do so from both sides of a relation. A :one
# link is set using "