Permalink
Browse files

Adding Document#to_a

  • Loading branch information...
1 parent 338126f commit 40f2eff81d185e71833fcfba792b2b03deaf066f @durran durran committed Dec 26, 2009
Showing with 14 additions and 0 deletions.
  1. +5 −0 lib/mongoid/document.rb
  2. +9 −0 spec/unit/mongoid/document_spec.rb
View
@@ -249,6 +249,11 @@ def root
object || self
end
+ # Return an array with this +Document+ only in it.
+ def to_a
+ [ self ]
+ end
+
# Returns the id of the Document, used in Rails compatibility.
def to_param
id
@@ -527,6 +527,15 @@
end
+ describe "#to_a" do
+
+ it "returns an array with the document in it" do
+ person = Person.new
+ person.to_a.should == [ person ]
+ end
+
+ end
+
describe "#to_param" do
it "returns the id" do

0 comments on commit 40f2eff

Please sign in to comment.