From: John Butler Date: 2008-05-30T03:03:27+09:00 Subject: Re: Merge collections of objects Robert Klemme wrote: > 2008/5/29 John Butler : >> Copy any employees from companyB that are not in companyA >> passing through the 2 objects and the relationship in dyn_method: >> dyn_method = 'company_employees' >> companyA.send(dyn_method + '=',companyB.send(dyn_method)) >> Thats pretty nice, as you say the struct is pretty similar to the hash so multiple keys can be checked for duplicates. This is how i have it working now but i may change to your solution above. My solution doesnt feel the most effecient. for obj in company_b.send(dyn_method) if !company_a.send(dyn_method).detect { |t| t.id == obj.id} company_a.send(dyn_method) << obj end end -- Posted via http://www.ruby-forum.com/.