From 9c43c2ab5fb92378c044cc472f1a838ffc577fa3 Mon Sep 17 00:00:00 2001 From: Joseph Kotanchik Date: Mon, 20 May 2024 13:46:30 -0400 Subject: [PATCH] MAT-7190: Move mongoid ObjectId Override to service class because I cearly do not understand how file loading works in ruby. --- model/mongoid.rb | 11 ----------- service/app.rb | 12 ++++++++++++ 2 files changed, 12 insertions(+), 11 deletions(-) delete mode 100644 model/mongoid.rb diff --git a/model/mongoid.rb b/model/mongoid.rb deleted file mode 100644 index 271f025..0000000 --- a/model/mongoid.rb +++ /dev/null @@ -1,11 +0,0 @@ -# Override the as_json method to ensure the _id is displayed as -# just the _id value as a string in the QRDA XML, "<_id>". -# Without this override it will be serialized as extended -# BSON::JSON, "{$oid => "<_id>"}" -module BSON - class ObjectId - def as_json(*args) - to_s.as_json - end - end -end \ No newline at end of file diff --git a/service/app.rb b/service/app.rb index e12c4cf..387ea70 100644 --- a/service/app.rb +++ b/service/app.rb @@ -10,6 +10,18 @@ puts "Loading QRDA Export Service" +# Override the as_json method to ensure the _id is displayed as +# just the _id value as a string in the QRDA XML, "<_id>". +# Without this override it will be serialized as extended +# BSON::JSON, "{$oid => "<_id>"}" +module BSON + class ObjectId + def as_json(*args) + to_s.as_json + end + end +end + Mongoid.load!("config/mongoid.yml") use Rack::JSONBodyParser