Class: ActiveRdfAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/active_rdf/federation/active_rdf_adapter.rb

Overview

Generic superclass of all adapters

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeActiveRdfAdapter

Returns a new instance of ActiveRdfAdapter.



10
11
12
# File 'lib/active_rdf/federation/active_rdf_adapter.rb', line 10

def initialize
  @enabled = true
end

Class Method Details

.supports_context?Boolean

Indicates if this adapter class supports contexts

Returns:

  • (Boolean)


35
36
37
38
# File 'lib/active_rdf/federation/active_rdf_adapter.rb', line 35

def self.supports_context?
  @context_supported = false if(@context_supported == nil)
  @context_supported
end

Instance Method Details

#clearObject

Clear the adapter. Crude default implementation, which can be overwritten in subclasses. TODO: This queries all adapters, this may lead to problems…

Raises:



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

#supports_context?Boolean

Indicate if the adapter supports contexts

Returns:

  • (Boolean)


15
16
17
# File 'lib/active_rdf/federation/active_rdf_adapter.rb', line 15

def supports_context?
  self.class.supports_context?
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