Skip to content

Instantly share code, notes, and snippets.

@jcoyne
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jcoyne/22108916b6c99fa434f3 to your computer and use it in GitHub Desktop.
Save jcoyne/22108916b6c99fa434f3 to your computer and use it in GitHub Desktop.
class CollectionMetadata < ActiveFedora::NtriplesRDFDatastream
property :member_list, predicate: RDF::DC.relation, class_name: 'ActiveFedora::Rdf::List'
end
require 'ostruct'
fake_obj = OpenStruct.new(pid: 'fake:123')
ds = CollectionMetadata.new(fake_obj, 'fakeDS')
l = ds.member_list.first_or_create
l << 'one'
l << 'two'
l << 'three'
puts ds.serialize
<info:fedora/fake:123> <http://purl.org/dc/terms/relation> _:g70356294539520 .
_:g70356294539520 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/1999/02/22-rdf-syntax-ns#List> .
_:g70356294539520 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> "one" .
=> nil
@jcoyne
Copy link
Author

jcoyne commented Jun 26, 2014

It looks like the list's graph isn't merged with the datastreams graph:

puts ds.graph.dump(:ntriples)
<info:fedora/fake:123> <http://purl.org/dc/terms/relation> _:g70356294539520 .
_:g70356294539520 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/1999/02/22-rdf-syntax-ns#List> .
_:g70356294539520 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> "one" .
=> nil
irb(main):022:0> puts l.dump(:ntriples)
_:g70356294539520 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/1999/02/22-rdf-syntax-ns#List> .
_:g70356294539520 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> "one" .
_:g70356294539520 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> _:g70356294385940 .
_:g70356294385940 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> "two" .
_:g70356294385940 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> _:g70356294337880 .
_:g70356294337880 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> "three" .
_:g70356294337880 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> .
=> nil

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment