Created alias Collection#size for Collection#count

This commit is contained in:
Kyle Banker 2009-10-13 16:20:41 -04:00
parent d1a07f4b36
commit 5ea585a475
2 changed files with 13 additions and 0 deletions

View File

@ -395,6 +395,8 @@ EOS
find().count() find().count()
end end
alias :size :count
protected protected
def normalize_hint_fields(hint) def normalize_hint_fields(hint)

View File

@ -112,6 +112,17 @@ class TestCollection < Test::Unit::TestCase
assert_equal 2, @@test.count assert_equal 2, @@test.count
end end
# Note: #size is just an alias for #count.
def test_size
@@test.drop
assert_equal 0, @@test.count
assert_equal @@test.size, @@test.count
@@test.save("x" => 1)
@@test.save("x" => 2)
assert_equal @@test.size, @@test.count
end
def test_find_one def test_find_one
id = @@test.save("hello" => "world", "foo" => "bar") id = @@test.save("hello" => "world", "foo" => "bar")