Return an object instead of an array if inserting only one object in collection

This commit is contained in:
Adrian Madrid 2008-12-05 17:02:35 -07:00
parent 4ccb68b870
commit 33c1702596

View File

@ -33,7 +33,8 @@ module XGen
def insert(*objects)
objects = objects.first if objects.size == 1 && objects.first.is_a?(Array)
@db.insert_into_db(@name, objects)
res = @db.insert_into_db(@name, objects)
res.size > 1 ? res : res.first
end
alias :<< :insert