Collection#build syntactic surgar
Closed this issue · 1 comments
bdurand commented
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}
bdurand commented
Oops, alias_method won't work (wrong return value). Should be:
def build (value)
value = convert(value)
self << value
value
end