spohlenz/mongomodel

Collection#build syntactic surgar

Closed this issue · 1 comments

What do you think of adding to Collection

alias_method :build, :<<

It just looks a little more readable to build up collections from value hashes with:

collection.build(:name => "Test", :value => 10)

instead of:

collection << {:name => "Test", :value => 10}

Oops, alias_method won't work (wrong return value). Should be:

def build (value)
  value = convert(value)
  self << value
  value
end