Return an object instead of an array if inserting only one object in collection
This commit is contained in:
parent
4ccb68b870
commit
33c1702596
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue