lib/pupa/processor/persistence.rb in pupa-0.0.11 vs lib/pupa/processor/persistence.rb in pupa-0.0.12
- old
+ new
@@ -22,11 +22,11 @@
when 0
nil
when 1
query.first
else
- raise Errors::TooManyMatches, "selector matches multiple documents during find: #{collection_name} #{MultiJson.dump(selector)}"
+ raise Errors::TooManyMatches, "selector matches multiple documents during find: #{collection_name} #{JSON.dump(selector)}"
end
end
# Inserts or replaces a document in MongoDB.
#
@@ -45,16 +45,17 @@
[true, @object._id.to_s]
end
end
when 1
# Make the document available to the callbacks.
+ # @see https://github.com/opennorth/pupa-ruby/issues/17
@object.document = query.first
@object.run_callbacks(:save) do
query.update(@object.to_h(persist: true).except(:_id))
[false, @object.document['_id'].to_s]
end
else
- raise Errors::TooManyMatches, "selector matches multiple documents during save: #{collection_name} #{MultiJson.dump(selector)}"
+ raise Errors::TooManyMatches, "selector matches multiple documents during save: #{collection_name} #{JSON.dump(selector)} for #{@object._id}"
end
end
private