Skip to content

MONGOID-5162 - Remove BSON::ObjectId#as_json as we will defer to the bson-ruby gem implementation #5057

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions lib/mongoid/extensions.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
# frozen_string_literal: true

class BSON::ObjectId
def as_json(options = nil)
{ "$oid" => to_s }
end
end

class BSON::Document
# We need to override this as ActiveSupport creates a new Object, instead of a new Hash
# see https://github.com/rails/rails/commit/f1bad130d0c9bd77c94e43b696adca56c46a66aa
Expand Down
14 changes: 0 additions & 14 deletions spec/mongoid/extensions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,6 @@

require "spec_helper"

describe BSON::ObjectId do

describe "#as_json" do

let(:object_id) do
described_class.new
end

it "returns the $oid plus string" do
expect(object_id.as_json).to eq("$oid" => object_id.to_s)
end
end
end

describe BSON::Document do

describe "#symbolize_keys" do
Expand Down