Class: Match::SKOS::Base
- Inherits:
-
Base
- Object
- Base
- Match::SKOS::Base
- Defined in:
- app/models/match/skos/base.rb
Direct Known Subclasses
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.build_from_rdf(subject, predicate, object) ⇒ Object
5 6 7 8 9 10 11 |
# File 'app/models/match/skos/base.rb', line 5 def self.build_from_rdf(subject, predicate, object) raise "Note::SKOS::Base#build_from_rdf: Subject (#{subject}) must be able to recieve this kind of notes (#{self.name} => #{self.name.to_relation_name})." unless subject.class.reflections.include?(self.name.to_relation_name) raise "Note::SKOS::Base#build_from_rdf: Object (#{object}) must be a URI" unless object =~ /^<(.+)>$/ uri = $1 subject.send(self.name.to_relation_name) << self.new(:value => uri) end |
Instance Method Details
#build_rdf(document, subject) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'app/models/match/skos/base.rb', line 13 def build_rdf(document, subject) raise "Match::SKOS::Base#build_rdf: Class #{self.name} needs to define self.rdf_namespace and self.rdf_predicate." unless self.rdf_namespace && self.rdf_predicate if (IqRdf::Namespace.find_namespace_class(self.rdf_namespace.camelcase)) subject.send(self.rdf_namespace.camelcase).send(self.rdf_predicate, URI.parse(value)) else raise "Match::SKOS::MappingRelation#build_rdf: couldn't find Namespace '#{self.rdf_namespace.camelcase}'." end end |