module ROF::Translators::JsonldToRof::PredicateHandler
Responsible for dealing with registered predicates and how those are handled.
The two primary entry points are `.call` and `.register`
@see ROF::Translators::JsonldToRof::PredicateHandler.call
@see ROF::Translators::JsonldToRof::PredicateHandler.register
Public Class Methods
@api public
Parse the RDF predicate and RDF object and add it's contents to the accumulator
@see ./spec/lib/rof/translators/jsonld_to_rof/predicate_handler_spec.rb for details and usage usage @see ROF::Translators::JsonldToRof::PredicateHandler.register
for setup
@example
Given the following 4 RDF N-Triples (subject, predicate, object). The first two, with subject "_:b0" represent blank nodes. The last one with subject "<https://curate.nd.edu/show/zk51vd69n1r>" has an object that points to the "_:b0" blank node. _:b0 <http://purl.org/dc/terms/contributor> "David R.Hyde" . _:b0 <http://www.ndltd.org/standards/metadata/etdms/1.1/role> "Research Director" . <https://curate.nd.edu/show/zk51vd69n1r> <http://purl.org/dc/terms/contributor> _:b0 . <https://curate.nd.edu/show/zk51vd69n1r> <http://projecthydra.org/ns/relations#hasEditorGroup> <https://curate.nd.edu/show/q524jm23g92> . For the first two N-Triples you would get a BlankNodeHandler; For the last two, you would get a UriSubjectHandler
@note It is assumed that all blank nodes (e.g. RDF::Node) will be processed before you process any RDF::URI nodes.
@param [RDF::Predicate] predicate - the RDF predicate that we will parse and add to the appropriate spot in the accumulator @param [RDF::Object] object - the RDF object that we will parse and add to the appropriate spot in the accumulator @param [ROF::Translators::JsonldToRof::Accumulator] accumulator - a data accumulator that will be changed in place @return [ROF::Translators::JsonldToRof::Accumulator] the given accumulator @raise [ROF::Translators::JsonldToRof::UnhandledPredicateError] when we are unable to handle the given predicate
# File lib/rof/translators/jsonld_to_rof/predicate_handler.rb, line 42 def self.call(predicate, object, accumulator, blank_node = false) handler = registry.handler_for(predicate) handler.handle(object, accumulator, blank_node) accumulator end
@api public
Register a map of an RDF Predicate URL to it's spot in the ROF
Hash.
@see ROF::Translators::JsonldToRof::PredicateHandler.call
for usage
@param [String] url - The URL that we want to match against @yield The block to configure how we handle RDF Predicates that match the gvien URL @yieldparam [ROF::JsonldToRof::PredicateHandler::UrlHandler] @see ./spec/lib/rof/translators/jsonld_to_rof/predicate_handler_spec.rb for details and usage usage
# File lib/rof/translators/jsonld_to_rof/predicate_handler.rb, line 58 def self.register(url, &block) registry << UrlHandler.new(url, &block) end
Private Class Methods
# File lib/rof/translators/jsonld_to_rof/predicate_handler.rb, line 68 def self.clear_registry!(set_with = RegistrySet.new) @registry = set_with end
@api private
# File lib/rof/translators/jsonld_to_rof/predicate_handler.rb, line 63 def self.registry @registry ||= RegistrySet.new end