lib/redlander/query/results.rb in redlander-0.6.1 vs lib/redlander/query/results.rb in redlander-0.6.2

- old
+ new

@@ -2,20 +2,29 @@ module Query # @api private class Results include Enumerable + class << self + private + + # @api private + def finalize_query(rdf_query_ptr) + proc { Redland.librdf_free_query(rdf_query_ptr) } + end + end + # (see Model#query) def initialize(q, options = {}) language = options[:language] || "sparql10" language_uri = options[:language_uri] && options[:language_uri].to_s base_uri = options[:base_uri] && options[:base_uri].to_s @rdf_query = Redland.librdf_new_query(Redlander.rdf_world, language, language_uri, q, base_uri) raise RedlandError, "Failed to create a #{language.upcase} query from '#{q}'" if @rdf_query.null? - ObjectSpace.define_finalizer(self, proc { Redland.librdf_free_query(@rdf_query) }) + ObjectSpace.define_finalizer(self, self.class.send(:finalize_query, @rdf_query)) end def process(model) @rdf_results = Redland.librdf_model_query_execute(model.rdf_model, @rdf_query) @@ -73,9 +82,10 @@ end def syntax? !Redland.librdf_query_results_is_syntax(@rdf_results).zero? end + private def process_bindings {}.tap do |bindings|