lib/json/ld/api.rb in json-ld-0.9.0 vs lib/json/ld/api.rb in json-ld-0.9.1

- old
+ new

@@ -362,27 +362,27 @@ # @raise [InvalidContext] # @return [Array<RDF::Statement>] if no block given # @yield statement # @yieldparam [RDF::Statement] statement def self.toRDF(input, context = nil, callback = nil, options = {}, &block) + results = [] API.new(input, context, options) do |api| # 1) Perform the Expansion Algorithm on the JSON-LD input. # This removes any existing context to allow the given context to be cleanly applied. result = api.expand(api.value, nil, api.context) api.send(:debug, ".expand") {"expanded input: #{result.to_json(JSON_STATE)}"} # Start generating statements - results = [] api.statements("", result, nil, nil, nil) do |statement| callback ||= block if block_given? if callback callback.call(statement) else results << statement end end - results end + results end ## # Take an ordered list of RDF::Statements and turn them into a JSON-LD document. #