Skip to content

Commit

Permalink
Removing document_class
Browse files Browse the repository at this point in the history
  • Loading branch information
durran committed Oct 18, 2009
1 parent 39b46a2 commit 9633197
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 19 deletions.
4 changes: 0 additions & 4 deletions lib/mongoid.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ module Mongoid
# Raised when the database connection has not been set up.
class NoConnectionError < RuntimeError; end

# Raised when :document_class is not provided in the attributes
# hash when creating a new Document
class ClassNotProvidedError < RuntimeError; end

# Raised when an association is defined on the class, but the
# attribute in the hash is not an Array or Hash.
class TypeMismatchError < RuntimeError; end
Expand Down
6 changes: 3 additions & 3 deletions spec/integration/mongoid/document_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
describe "#find" do

before do
@person = Person.create(:title => "Test", :document_class => "Person")
@person = Person.create(:title => "Test")
end

context "finding all documents" do
Expand Down Expand Up @@ -64,7 +64,7 @@

before do
30.times do |num|
Person.create(:title => "Sir", :age => num, :document_class => "Person")
Person.create(:title => "Sir", :age => num)
end
end

Expand All @@ -82,7 +82,7 @@

before do
30.times do |num|
Person.create(:title => "Test-#{num}", :document_class => "Person")
Person.create(:title => "Test-#{num}")
end
end

Expand Down
8 changes: 4 additions & 4 deletions spec/unit/mongoid/associations/has_many_association_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
@first_id = Mongo::ObjectID.new
@second_id = Mongo::ObjectID.new
@attributes = { :addresses => [
{ :_id => @first_id, :street => "Street 1", :document_class => "Address" },
{ :_id => @second_id, :street => "Street 2", :document_class => "Address" } ] }
{ :_id => @first_id, :street => "Street 1" },
{ :_id => @second_id, :street => "Street 2" } ] }
@document = stub(:attributes => @attributes)
end

Expand Down Expand Up @@ -88,14 +88,14 @@
end

it "adds a new document to the array with the suppied parameters" do
@association.build({ :street => "Street 1", :document_class => "Address" })
@association.build({ :street => "Street 1" })
@association.length.should == 3
@association[2].should be_a_kind_of(Address)
@association[2].street.should == "Street 1"
end

it "returns the newly built object in the association" do
address = @association.build({ :street => "Yet Another", :document_class => "Address" })
address = @association.build({ :street => "Yet Another" })
address.should be_a_kind_of(Address)
address.street.should == "Yet Another"
end
Expand Down
16 changes: 8 additions & 8 deletions spec/unit/mongoid/document_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
describe "#find" do

before do
@attributes = { :document_class => "Person" }
@attributes = {}
@criteria = mock
end

Expand Down Expand Up @@ -198,7 +198,7 @@
describe "#first" do

before do
@attributes = { :document_class => "Person" }
@attributes = {}
end

context "when a selector is provided" do
Expand Down Expand Up @@ -259,13 +259,13 @@
before do
@attributes = { :title => "Sir",
:addresses => [
{ :street => "Street 1", :document_class => "Address" },
{ :street => "Street 2", :document_class => "Address" } ] }
{ :street => "Street 1" },
{ :street => "Street 2" } ] }
@person = Person.new(@attributes)
end

it "sets the attributes for the association" do
address = Address.new(:street => "New Street", :document_class => "Address")
address = Address.new(:street => "New Street")
@person.addresses = [address]
@person.addresses.first.street.should == "New Street"
end
Expand Down Expand Up @@ -300,7 +300,7 @@
end

it "sets the attributes for the association" do
name = Name.new(:first_name => "New Name", :document_class => "Name")
name = Name.new(:first_name => "New Name")
@person.name = name
@person.name.first_name.should == "New Name"
end
Expand Down Expand Up @@ -439,8 +439,8 @@
before do
@attributes = { :title => "Sir",
:addresses => [
{ :street => "Street 1", :document_class => "Address" },
{ :street => "Street 2", :document_class => "Address" } ] }
{ :street => "Street 1" },
{ :street => "Street 2" } ] }
@person = Person.new(@attributes)
end

Expand Down

0 comments on commit 9633197

Please sign in to comment.