Module: Tripod::Repository::ClassMethods
- Defined in:
- lib/tripod/repository.rb
Instance Method Summary collapse
-
#add_data_to_repository(graph, repo = nil) ⇒ Object
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.
- #all_triples_construct(uri) ⇒ Object
- #all_triples_query(uri, opts = {}) ⇒ Object
- #all_triples_where(uri) ⇒ Object
- #append_to_hydrate_construct(statement) ⇒ Object
- #append_to_hydrate_where(statement) ⇒ Object
Instance Method Details
#add_data_to_repository(graph, repo = nil) ⇒ Object
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.
75 76 77 78 79 80 81 82 83 84 |
# 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) ⇒ Object
103 104 105 106 |
# 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 = {}) ⇒ Object
96 97 98 99 100 101 |
# 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) ⇒ Object
108 109 110 111 |
# 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) ⇒ Object
86 87 88 89 |
# File 'lib/tripod/repository.rb', line 86 def append_to_hydrate_construct(statement) @construct_statements ||= [] @construct_statements << statement end |
#append_to_hydrate_where(statement) ⇒ Object
91 92 93 94 |
# File 'lib/tripod/repository.rb', line 91 def append_to_hydrate_where(statement) @where_statements ||= [] @where_statements << statement end |