From: Matt Mencel Date: 2010-04-02T04:59:38+09:00 Subject: Re: Dynamic Method Calls This did it...thanks for the assistance... :) c.send("#{k.downcase}=", "#{v}") Every record.attributes value is an Array, even if they are single-valued. When I store the data into the LdapAccount model...it just stores the data as a String. Which is fine for single-valued arrays, but the multi-valued is a problem. I could do the following... c.send("#{k.downcase}=", "#{v.inspect}") Which would store every single or multi valued array in the model as a String like so... single: ["SOMEVAL"] multi: ["val1","val2","val3",etc...] But that may be more work when I want to pull that data back out at some point in the future. Should I store the single valued attributes as a plain String and the multi-valued attributes as an Array String like above? Something like this maybe... LdapAccount.create(:uid => record.attributes["uid"].to_s) do |c| record.attributes.each_pair do |k,v| # v is an array of single or multi attribute values if v.size > 1 c.send("#{k.downcase}=", "#{v.inspect}") else c.send("#{k.downcase}=", "#{v}") end end end Any thoughts? Thanks, Matt ----- Original Message ----- From: "Ryan Davis" To: "ruby-talk ML" Sent: Thursday, April 1, 2010 1:42:56 PM Subject: Re: Dynamic Method Calls On Apr 1, 2010, at 11:35 , Andrea Dallera wrote: > Whoopsie, i'm really sorry. It should be something like: > > c.send("#{k}=".to_sym, v) .to_sym is unnecessary