module ActiveTriples::RDFSource::ClassMethods
Class methods for RDFSource
, included via ActiveSupport
Public Instance Methods
Apply a predicate mapping using a given strategy.
@param [ActiveTriples::Schema, properties] schema A schema to apply. @param [#apply!] strategy A strategy for applying. Defaults
to ActiveTriples::ExtensionStrategy
# File lib/active_triples/rdf_source.rb, line 735 def apply_schema(schema, strategy = ActiveTriples::ExtensionStrategy) schema.properties.each { |property| strategy.apply(self, property) } end
Adapter for a consistent interface for creating a new Resource
from a URI. Similar functionality should exist in all objects which can become a Resource
.
@param uri [#to_uri, String] @param args values to pass as arguments to ::new
@return [ActiveTriples::Entity] a Resource
with the given uri
# File lib/active_triples/rdf_source.rb, line 725 def from_uri(uri, *args) new(uri, *args) end
Test if the rdf_subject that would be generated using a specific ID is already in use in the triplestore.
@param [Integer, read] ID to test
@return [TrueClass, FalseClass] true, if the ID is in
use in the triplestore; otherwise, false. NOTE: If the ID is in use in an object not yet persisted, false will be returned presenting a window of opportunity for an ID clash.
# File lib/active_triples/rdf_source.rb, line 750 def id_persisted?(test_id) rdf_subject = new(test_id).rdf_subject ActiveTriples::Repositories.has_subject?(rdf_subject) end
Test if the rdf_subject that would be generated using a specific URI is already in use in the triplestore.
@param [String, RDF::URI, read] URI to test
@return [TrueClass, FalseClass] true, if the URI is in
use in the triplestore; otherwise, false. NOTE: If the URI is in use in an object not yet persisted, false will be returned presenting a window of opportunity for an ID clash.
# File lib/active_triples/rdf_source.rb, line 767 def uri_persisted?(test_uri) test_uri = RDF::URI.intern(test_uri) unless test_uri.is_a?(RDF::URI) ActiveTriples::Repositories.has_subject?(test_uri) end