Last active
August 29, 2015 13:57
-
-
Save no-reply/9842656 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SomethingDatastream < ActiveFedora::NtriplesRDFDatastream | |
property :contributor, predicate: RDF::URI('http://example.org/ns/contributor'), class_name: 'Contributor' | |
end | |
class Contributor < ActiveFedora::Rdf::Resource | |
configure type: RDF::URI('http://example.org/ns/Contributor') | |
property :name, predicate: RDF::FOAF.name | |
end | |
class Something < ActiveFedora::Base | |
has_metadata 'descMetadata', type: SomethingDatastream | |
has_attributes :contributor, datastream: 'descMetadata', multiple: true | |
end | |
c = Contributor.new('http://orcid.org/0000-0002-1191-0873') | |
s = Something.new | |
s.contributor << c | |
s.contributor << 'Don Brower' | |
s.contributor | |
#=> [#<Contributor:0x3fecdd798bdc(default)>, "Don Brower"] | |
s.dump :ntriples | |
# => "_:g70286560324780 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.org/ns/Contributor> .\n_:g70286560371240 <http://example.org/ns/contributor> <http://orcid.org/0000-0002-1191-0873> .\n_:g70286560371240 <http://example.org/ns/contributor> \"Don Brower\" .\n<http://orcid.org/0000-0002-1191-0873> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.org/ns/Contributor> .\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Probably worth noting, given your 'translating user input' use case, that this will work too: