[Nitro] in... vain...

Humber Aquino humberaquino at gmail.com
Sun Dec 25 17:50:17 EST 2005

puts "foo1.bars returns an #{foo1.bars .class} object"

> # next line should work, but it does not
> foo_foobars = foo1.bars.foobars

# returns an object of the class  Og::HasManyCollection. This class is
a subclass of Og::Collection

# Og::HasManyCollection just inherits from Og::Collection
# Og::Collection has this public methods
# []    check_type    delete    delete_all    delete_if    each   
load_members    method_missing    new    push    reload    remove   
#remove_all    size    to_ary    unload

# And none of them loads all "foobars" for each bar in foo..

# If you want a clean logic has that you can define a method in your
foo class as this
def foobars
	result = []
	bars.each { |bar| result.concat(bar.foobars) }
	return result

#And try the call
foo_foobars = foo1.foobars	

# I don't know if og does this automatically, but it would be a nice feature


More information about the Nitro-general mailing list