[BioRuby] [GSoC] ORM styled NeXML
Anurag Priyam
anurag08priyam at gmail.com
Thu Jul 29 16:45:11 UTC 2010
An object invocation of NeXML is very much ORM like. An Otus and a Tree
class could very well be represented as:
class Otus
include Mapper
property :id, :label
has_n :trees
end
class Trees
include Mapper
property :id, :label
belongs_to :otus
end
And, one would be able to do following:
otus1.trees << trees1
otus1.trees = [ trees2, trees3]
otus1.trees
# => trees1, trees2, trees3
trees1.otus
# => otus1
NeXML::Mapper module defines the magic methods property, has_n, and
belongs_to which will use reflection to define the needed methods.
The above representation of Otus and Trees class feels very succinct to me.
It could be due to my Rails/Merb background but, others can see it as a DSL.
What is the take of others on this coding style( including acceptance in
BioRuby ) ?
--
Anurag Priyam,
3rd Year Undergraduate,
Department of Mechanical Engineering,
IIT Kharagpur.
+91-9775550642
More information about the BioRuby
mailing list