ncbo / goo

Graph Oriented Objects (GOO) for Ruby. A RDF/SPARQL based ORM.
http://ncbo.github.io/goo/
Other
15 stars 6 forks source link

DSL support for aliasing attributes #64

Open palexander opened 11 years ago

palexander commented 11 years ago

There are cases where Goo objects may need to reference attributes that exist on other Goo objects, generally when you have a container object (Ontology) and related objects (OntologySubmission). For example, when serializing OntologySubmission you want to display the acronym, groups, etc which only exist on the Ontology object.

Here's a sample syntax

class Ontology
  attribute :acronym, :unique => true
  attribute :creator
end

class OntologySubmission
  attribute :submissionId, :unique => true
  attribute :ontology, :instance_of => {:with => :ontology}
  # Default
  alias_attribute :acronym, :instance_of => {:with => :ontology}
  # Change the attribute name
  alias_attribute :author :instance_of => {:with => :ontology, :attribute => :creator}
end

Not sure if this should support read/write or just read