module Tripod::Repository::ClassMethods

Public Instance Methods

add_data_to_repository(graph, repo=nil) click to toggle source
for triples in the graph passed in, add them to the passed in repository obj, and return the repository objects

 if no repository passed, make a new one.

# File lib/tripod/repository.rb, line 75
def add_data_to_repository(graph, repo=nil)

  repo ||= RDF::Repository.new()

  graph.each_statement do |statement|
    repo << statement
  end

  repo
end
all_triples_construct(uri) click to toggle source
# File lib/tripod/repository.rb, line 103
def all_triples_construct(uri)
  extra_construct = @construct_statements.map{|s| s.call(uri) }.join if @construct_statements.present?
  extra_construct || ''
end
all_triples_query(uri, opts={}) click to toggle source
# File lib/tripod/repository.rb, line 96
def all_triples_query(uri, opts={})
  graph_uri = opts.fetch(:graph_uri, nil)
  graph_selector = graph_uri.present? ? "<#{graph_uri.to_s}>" : "?g"
  uri_selector = "<#{uri}>"
  "CONSTRUCT { #{uri_selector} ?p ?o . #{ all_triples_construct(uri_selector) } } WHERE { GRAPH #{graph_selector} { #{uri_selector} ?p ?o . #{ all_triples_where(uri_selector) } } }"
end
all_triples_where(uri) click to toggle source
# File lib/tripod/repository.rb, line 108
def all_triples_where(uri)
  extra_where = @where_statements.map{|s| s.call(uri) }.join if @where_statements.present?
  extra_where || ''
end
append_to_hydrate_construct(statement) click to toggle source
# File lib/tripod/repository.rb, line 86
def append_to_hydrate_construct(statement)
  @construct_statements ||= []
  @construct_statements << statement
end
append_to_hydrate_where(statement) click to toggle source
# File lib/tripod/repository.rb, line 91
def append_to_hydrate_where(statement)
  @where_statements ||= []
  @where_statements << statement
end