Skip to content

Commit

Permalink
Remove the ::BSON alias in favor of Moped::BSON
Browse files Browse the repository at this point in the history
  • Loading branch information
rmm5t committed Jun 20, 2012
1 parent f99211e commit fab5cc8
Show file tree
Hide file tree
Showing 37 changed files with 258 additions and 267 deletions.
9 changes: 0 additions & 9 deletions lib/mongoid.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,3 @@ def session(name)
ActiveModel::Observing::ClassMethods.public_instance_methods(false) <<
{ to: Config }))
end

# Assign a BSON namespace shortcut, but avoid a BSON namespace collision if the
# 10gen driver is detected. This is placed after all other requires to partially
# help ensure that the mongoid library itself doesn't use the shortcut.
begin
require "bson"
rescue LoadError
BSON = Moped::BSON
end
2 changes: 1 addition & 1 deletion spec/app/models/person.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Person
field :owner_id, type: Integer
field :security_code
field :reading, type: Object
field :bson_id, type: BSON::ObjectId
field :bson_id, type: Moped::BSON::ObjectId
field :pattern, type: Regexp
field :override_me, type: Integer

Expand Down
2 changes: 1 addition & 1 deletion spec/app/models/registry.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Registry
include Mongoid::Document
field :data, type: BSON::Binary
field :data, type: Moped::BSON::Binary
end
2 changes: 1 addition & 1 deletion spec/mongoid/atomic/modifiers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@
context "when the sets contain an id" do

let(:sets) do
{ "_id" => BSON::ObjectId.new }
{ "_id" => Moped::BSON::ObjectId.new }
end

before do
Expand Down
16 changes: 8 additions & 8 deletions spec/mongoid/attributes_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -376,9 +376,9 @@
after(:all) do
Person.field(
:_id,
type: BSON::ObjectId,
type: Moped::BSON::ObjectId,
pre_processed: true,
default: ->{ BSON::ObjectId.new }
default: ->{ Moped::BSON::ObjectId.new }
)
end

Expand All @@ -387,9 +387,9 @@
before(:all) do
Person.field(
:_id,
type: BSON::ObjectId,
type: Moped::BSON::ObjectId,
pre_processed: true,
default: ->{ BSON::ObjectId.new }
default: ->{ Moped::BSON::ObjectId.new }
)
end

Expand All @@ -398,7 +398,7 @@
end

let(:bson_id) do
BSON::ObjectId.new
Moped::BSON::ObjectId.new
end

context "when providing an object id" do
Expand Down Expand Up @@ -442,7 +442,7 @@
:_id,
type: String,
pre_processed: true,
default: ->{ BSON::ObjectId.new.to_s }
default: ->{ Moped::BSON::ObjectId.new.to_s }
)
end

Expand All @@ -451,7 +451,7 @@
end

let(:bson_id) do
BSON::ObjectId.new
Moped::BSON::ObjectId.new
end

context "when providing an object id" do
Expand Down Expand Up @@ -627,7 +627,7 @@
context "when supplied hash has string values" do

let(:bson_id) do
BSON::ObjectId.new
Moped::BSON::ObjectId.new
end

let!(:attributes) do
Expand Down
24 changes: 12 additions & 12 deletions spec/mongoid/criteria_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@
describe "#extract_id" do

let(:id) do
BSON::ObjectId.new
Moped::BSON::ObjectId.new
end

context "when an id exists" do
Expand Down Expand Up @@ -749,7 +749,7 @@
end

let(:found) do
Band.find(BSON::ObjectId.new)
Band.find(Moped::BSON::ObjectId.new)
end

it "raises an error" do
Expand All @@ -770,7 +770,7 @@
end

let(:found) do
Band.find(BSON::ObjectId.new)
Band.find(Moped::BSON::ObjectId.new)
end

it "returns nil" do
Expand Down Expand Up @@ -820,7 +820,7 @@
end

let(:found) do
Band.find(band.id, BSON::ObjectId.new)
Band.find(band.id, Moped::BSON::ObjectId.new)
end

it "raises an error" do
Expand All @@ -841,7 +841,7 @@
end

let(:found) do
Band.find(band.id, BSON::ObjectId.new)
Band.find(band.id, Moped::BSON::ObjectId.new)
end

it "returns only the matching documents" do
Expand Down Expand Up @@ -891,7 +891,7 @@
end

let(:found) do
Band.find([ band.id, BSON::ObjectId.new ])
Band.find([ band.id, Moped::BSON::ObjectId.new ])
end

it "raises an error" do
Expand All @@ -912,7 +912,7 @@
end

let(:found) do
Band.find([ band.id, BSON::ObjectId.new ])
Band.find([ band.id, Moped::BSON::ObjectId.new ])
end

it "returns only the matching documents" do
Expand All @@ -930,7 +930,7 @@
end

after(:all) do
Band.field :_id, type: BSON::ObjectId, default: ->{ BSON::ObjectId.new }
Band.field :_id, type: Moped::BSON::ObjectId, default: ->{ Moped::BSON::ObjectId.new }
end

let!(:band) do
Expand Down Expand Up @@ -1126,7 +1126,7 @@
end

after(:all) do
Band.field :_id, type: BSON::ObjectId, default: ->{ BSON::ObjectId.new }
Band.field :_id, type: Moped::BSON::ObjectId, default: ->{ Moped::BSON::ObjectId.new }
end

let!(:band) do
Expand Down Expand Up @@ -1787,7 +1787,7 @@
context "when querying on a foreign key" do

let(:id) do
BSON::ObjectId.new
Moped::BSON::ObjectId.new
end

let!(:match_one) do
Expand Down Expand Up @@ -3239,11 +3239,11 @@ def self.ages; self; end
context "when the criteria is an exact fk array match" do

let(:id_one) do
BSON::ObjectId.new
Moped::BSON::ObjectId.new
end

let(:id_two) do
BSON::ObjectId.new
Moped::BSON::ObjectId.new
end

let(:criteria) do
Expand Down
6 changes: 3 additions & 3 deletions spec/mongoid/dirty_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@
context "when the document has not changed" do

let(:acolyte) do
Acolyte.instantiate("_id" => BSON::ObjectId.new)
Acolyte.instantiate("_id" => Moped::BSON::ObjectId.new)
end

it "returns false" do
Expand Down Expand Up @@ -704,7 +704,7 @@
context "when the document has not changed" do

let(:acolyte) do
Acolyte.instantiate("_id" => BSON::ObjectId.new)
Acolyte.instantiate("_id" => Moped::BSON::ObjectId.new)
end

it "returns an empty hash" do
Expand Down Expand Up @@ -835,7 +835,7 @@
context "when the document has not changed" do

let(:acolyte) do
Acolyte.instantiate("_id" => BSON::ObjectId.new)
Acolyte.instantiate("_id" => Moped::BSON::ObjectId.new)
end

it "returns an empty hash" do
Expand Down
18 changes: 9 additions & 9 deletions spec/mongoid/document_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@
end

it "creates an id for the document" do
person.id.should be_a(BSON::ObjectId)
person.id.should be_a(Moped::BSON::ObjectId)
end

it "sets the attributes" do
Expand Down Expand Up @@ -423,7 +423,7 @@
context "when instantiating model" do

let(:person) do
Person.instantiate("_id" => BSON::ObjectId.new, "title" => "Sir")
Person.instantiate("_id" => Moped::BSON::ObjectId.new, "title" => "Sir")
end

before do
Expand Down Expand Up @@ -476,7 +476,7 @@
end

let(:id) do
BSON::ObjectId.new
Moped::BSON::ObjectId.new
end

let!(:person) do
Expand Down Expand Up @@ -596,7 +596,7 @@
context "when the document is not new" do

let(:person) do
Person.instantiate("_id" => BSON::ObjectId.new)
Person.instantiate("_id" => Moped::BSON::ObjectId.new)
end

it "returns the id in an array" do
Expand All @@ -607,7 +607,7 @@
context "when the document is destroyed" do

let(:person) do
Person.instantiate("_id" => BSON::ObjectId.new).tap do |peep|
Person.instantiate("_id" => Moped::BSON::ObjectId.new).tap do |peep|
peep.destroyed = true
end
end
Expand All @@ -634,7 +634,7 @@
context "when the document is not new" do

let(:person) do
Person.instantiate("_id" => BSON::ObjectId.new)
Person.instantiate("_id" => Moped::BSON::ObjectId.new)
end

it "returns the id as a string" do
Expand Down Expand Up @@ -750,10 +750,10 @@
end
end

context "defining a BSON::ObjectId as a field" do
context "defining a Moped::BSON::ObjectId as a field" do

let(:bson_id) do
BSON::ObjectId.new
Moped::BSON::ObjectId.new
end

let(:person) do
Expand All @@ -765,7 +765,7 @@
end

it "persists the correct type" do
person.reload.bson_id.should be_a(BSON::ObjectId)
person.reload.bson_id.should be_a(Moped::BSON::ObjectId)
end

it "has the correct value" do
Expand Down

0 comments on commit fab5cc8

Please sign in to comment.