Class: ActiveRDF::ActiveRdfAdapter
- Inherits:
-
Object
- Object
- ActiveRDF::ActiveRdfAdapter
- Defined in:
- lib/active_rdf/federation/active_rdf_adapter.rb
Instance Method Summary collapse
-
#clear ⇒ Object
Clear the adapter.
-
#initialize(params = {}) ⇒ ActiveRdfAdapter
constructor
A new instance of ActiveRdfAdapter.
-
#translate(query) ⇒ Object
translate a query to its string representation.
Constructor Details
#initialize(params = {}) ⇒ ActiveRdfAdapter
Returns a new instance of ActiveRdfAdapter.
10 11 12 13 14 15 16 17 |
# File 'lib/active_rdf/federation/active_rdf_adapter.rb', line 10 def initialize(params = {}) # defaults @enabled = true @reads = true @writes = truefalse(params[:write], true) @new = truefalse(params[:new], false) @contexts = truefalse(params[:contexts], false) end |
Instance Method Details
#clear ⇒ Object
Clear the adapter. Crude default implementation, which can be overwritten in subclasses. TODO: This queries all adapters, this may lead to problems…
26 27 28 29 30 31 32 |
# File 'lib/active_rdf/federation/active_rdf_adapter.rb', line 26 def clear raise(ActiveRdfError, "Can only delete from writing adapters") unless(writes?) to_delete = Query.new.select(:s, :p, :o).where(:s, :p, :o).execute to_delete.each do |s, p, o| delete(s, p, o) end end |
#translate(query) ⇒ Object
translate a query to its string representation
20 21 22 |
# File 'lib/active_rdf/federation/active_rdf_adapter.rb', line 20 def translate(query) Query2SPARQL.translate(query) end |