[Nitro] RDOG 0.2 (or something like that)

Andrew Thompson vagabond at cataclysm-software.net
Tue Sep 6 15:29:29 EDT 2005


You've asked me this about 3 times now George, I'll paste my testcase 
AGAIN, maybe this time you'll keep it somewhere handy :). I just want to 
have Classes and Methods both able to store Method objects...

Vag


============================

require 'rubygems'
require_gem 'og'

#turn on debugging
$DBG = true

class Doc
     property :name, String

     def initialize(name)
         @name = name
     end
end

class DocModule < Doc
     has_many :functions, DocMethod #contains many methods
end

class DocClass < DocModule
     many_to_many :modules, DocModule #may have many modules, and those 
modules may be in other classes
end

class DocMethod < Doc
     belongs_to :parent, DocModule #belong to a DocModule as DocClass is 
a subclass of DocModule
end

db = Og.setup(
       :store => 'mysql',
       :name => 'test',
       :user => 'bleh',
       :password => 'something'
)

testclass = DocClass.new('Testd')
testmethod = DocMethod.new('test')
testmodule = DocModule.new('module')

testmethod.parent = testclass

#save the objects

testclass.save
testmethod.save

#this works
testmethod.parent = testclass

#but reports no parents...
puts testmethod.parent

#this causes a crash
#testclass.add_function(testmethod)

#this causes a crash
#puts testclass.functions

===============================

George Moschovitis wrote:
>>(og still doesn't seem to want to play nice with inherited classes),
> 
> 
> what is the problem exactly?
> 
> -g.
> 
> 
> 




More information about the Nitro-general mailing list