module ActiveTriples::RDFSource::ClassMethods

Class methods for RDFSource, included via ActiveSupport

Public Instance Methods

apply_schema(schema, strategy = ActiveTriples::ExtensionStrategy) click to toggle source

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 712
def apply_schema(schema, strategy = ActiveTriples::ExtensionStrategy)
  schema.properties.each { |property| strategy.apply(self, property) }
end
from_uri(uri, *args) click to toggle source

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 702
def from_uri(uri, *args)
  new(uri, *args)
end
id_persisted?(test_id) click to toggle source

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 727
def id_persisted?(test_id)
  rdf_subject = new(test_id).rdf_subject

  ActiveTriples::Repositories.has_subject?(rdf_subject)
end
uri_persisted?(test_uri) click to toggle source

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 744
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