Swirrl / tripod

ActiveModel-style Ruby ORM for RDF Linked Data. Works with SPARQL 1.1 HTTP endpoints.
MIT License
58 stars 14 forks source link

Requirement for `rdf_type` should be explicit/ validated/ documented #27

Open Robsteranium opened 10 years ago

Robsteranium commented 10 years ago

Tripod resources require an rdf_type. When this is missing you can't find them. I'm not sure if they are not persisted or persisted but not retrievable.

Ideally this should be part of the validation, if it is to be required at all.

This is what happens without:

class Thing
  include Tripod::Resource
  graph_uri RDF::URI("http://example.org/graph/things") 
end

thing = Thing.new(RDF::URI("http://example.org/id/things/one"))
thing.save!

Thing.find(RDF::URI("http://example.org/id/things/one")) #=> raises Tripod::Errors::ResourceNotFound

It works ok when rdf_type is specified.

class Thing
  include Tripod::Resource
  graph_uri RDF::URI("http://example.org/graph/things") 
  rdf_type RDF::URI("http://example.org/def/thing")
end

thing = Thing.new(RDF::URI("http://example.org/id/things/one"))
thing.save!

thing == Thing.find(RDF::URI("http://example.org/id/things/one")) #=> true