aliased << to insert for collections
This commit is contained in:
parent
c3b1225605
commit
21e45c29b7
@ -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)
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user