lib/sparql/algebra/operator/union.rb in sparql-1.1.1 vs lib/sparql/algebra/operator/union.rb in sparql-1.1.2
- old
+ new
@@ -22,20 +22,25 @@
#
# @param [RDF::Queryable] queryable
# the graph or repository to query
# @param [Hash{Symbol => Object}] options
# any additional keyword options
+ # @yield [solution]
+ # each matching solution
+ # @yieldparam [RDF::Query::Solution] solution
+ # @yieldreturn [void] ignored
# @return [RDF::Query::Solutions]
# the resulting solution sequence
# @see http://www.w3.org/TR/rdf-sparql-query/#sparqlAlgebra
- def execute(queryable, options = {})
+ def execute(queryable, options = {}, &block)
debug(options) {"Union"}
- @solutions = RDF::Query::Solutions.new(operands.inject([]) do |memo, op|
+ @solutions = RDF::Query::Solutions(operands.inject([]) do |memo, op|
solns = op.execute(queryable, options.merge(:depth => options[:depth].to_i + 1))
debug(options) {"=> (op) #{solns.inspect}"}
memo + solns
end)
debug(options) {"=> #{@solutions.inspect}"}
+ @solutions.each(&block) if block_given?
@solutions
end
##
# Returns an optimized version of this query.