aliased << to insert for collections

This commit is contained in:
Jim Menard 2008-12-08 15:04:07 -05:00
parent c3b1225605
commit 21e45c29b7
2 changed files with 6 additions and 0 deletions

View File

@ -35,6 +35,7 @@ module XGen
objects = objects.first if objects.size == 1 && objects.first.is_a?(Array)
@db.insert_into_db(@name, objects)
end
alias_method :<<, :insert
def remove(selector={})
@db.remove_from_db(@name, selector)

View File

@ -33,6 +33,11 @@ class DBAPITest < Test::Unit::TestCase
assert docs.detect { |row| row['a'] == 1 }
assert docs.detect { |row| row['a'] == 2 }
assert docs.detect { |row| row['b'] == 3 }
@coll << {'b' => 4}
docs = @coll.find().collect
assert_equal 4, docs.length
assert docs.detect { |row| row['b'] == 4 }
end
def test_close