lib/pupa/processor/persistence.rb in pupa-0.0.8 vs lib/pupa/processor/persistence.rb in pupa-0.0.9

- 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} #{JSON.dump(selector)}" + raise Errors::TooManyMatches, "selector matches multiple documents during find: #{collection_name} #{MultiJson.dump(selector)}" end end # Saves an object to MongoDB. # @@ -39,17 +39,17 @@ # Run query before callbacks to avoid e.g. timestamps in the selector. @object.run_callbacks(:save) do case query.count when 0 @object.run_callbacks(:create) do - collection.insert(@object.to_h) + collection.insert(@object.to_h(persist: true)) @object._id.to_s end when 1 - query.update(@object.to_h) + query.update(@object.to_h(persist: true)) query.first['_id'].to_s else - raise Errors::TooManyMatches, "selector matches multiple documents during save: #{collection_name} #{JSON.dump(selector)}" + raise Errors::TooManyMatches, "selector matches multiple documents during save: #{collection_name} #{MultiJson.dump(selector)}" end end end private