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

Lambda/proc for naming resource model #37

Closed msalvadores closed 11 years ago

msalvadores commented 11 years ago

A dsl option in model

class X << Resource
   model :x ,
            :name_with => lambda { |record| IRI.new("http://xxx/"+record.attr }
end
msalvadores commented 11 years ago

@palexander lambda/procs can be used now to name resources in the ontologies linked API.

Sample model definition:

class SomeModel < Goo::Base::Resource
  model :name_with => lambda { |record| RDF::IRI.new( "http://xxx/"+ (record.values.join "-")) }
  attribute :values
  def initialize(attributes = {})
    super(attributes)
  end
end