class Redland::Query
This class provides query language support for RDF models either via an adaptor class or direct by persistant storage.
Attributes
query[R]
Public Class Methods
create_finalizer(query)
click to toggle source
You shouldn't use this. Used internally for cleanup.
# File lib/rdf/redland/query.rb, line 36 def Query.create_finalizer(query) proc{|id| # "Finalizer on #{id}" #$log_final.info "closing query" Redland::librdf_free_query(query) } end
new(query,language=nil,uri=nil,base_uri=nil)
click to toggle source
Constructor - create a new Query object query - the query string language - the name of the query language uri - the URI identifying the query language
# File lib/rdf/redland/query.rb, line 17 def initialize(query,language=nil,uri=nil,base_uri=nil) @language = language @uri = uri @query = Redland.librdf_new_query($world.world,language,uri,query,base_uri) return nil if not @query ObjectSpace.define_finalizer(self,Query.create_finalizer(@query)) end
Public Instance Methods
execute(model)
click to toggle source
Execute a query on a model
# File lib/rdf/redland/query.rb, line 26 def execute(model) results=Redland.librdf_query_execute(@query,model.model) if not results return nil else return QueryResults.new(results) end end