[Nitro] Help creating a ObjectGraph adapter for RubyAMF
Jonathan Buch
john at oxyliquit.de
Tue May 22 11:48:58 EDT 2007
Hi,
> ---For this line:
> result = SomeModel.find() # ask if you need more help with Og queries"
> ---Does object graph work the same way active record does? If there is
> one result it is a object ObjectGraph::Result. And if it is multiple
> rows it is an Array of ObjectGraph::Result. If not and it always
> returns an array, do any of the items in the array have a special
> class name (IE: result[0] -> ObjectGraph::Something?). That is how I
> am finding out that this "result" is an ObjectGraph result.
# Will always return an array if there are results, nil if there is no
# result. Array contents are always .kind_of?(Og::Model)
result = SomeModel.find()
# will return return a .kind_of?(Og::Model) or nil if nothing found
result = SomeModel.find_one()
So yes, you can rely on result[0].kind_of?(Og::Model) if somethings has
been found.
> ---For column names.
> Is there anyway I can get the column names off of the "result" object,
> not the "SomeModel" class. As when a result is returned to me I don't
> know about the models, just the resulting object.
Ah of course. :P As you can get the class from the object. :)
if result[0].kind_of?(Og::Model)
result[0].class.serializable_attributes
end
Jo
--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
More information about the Nitro-general
mailing list