Skip to content

Instantly share code, notes, and snippets.

@gerhard
Created November 23, 2008 16:17
Show Gist options
  • Select an option

  • Save gerhard/28147 to your computer and use it in GitHub Desktop.

Select an option

Save gerhard/28147 to your computer and use it in GitHub Desktop.
apeiros_: send accepts a method name. for x.foo = "bar", the method name is 'foo='
apeiros_: oh boy. macgerhard, x.send(method, *args)
apeiros_: your method is 'attrname='
apeiros_: your args is the value you want to assign
apeiros_: and there IS NO = after send. makes no sense.
>> a.attributes
=> {"address1"=>"Address1", "updated_at"=>nil, "address2"=>nil, "postcode"=>nil, "county"=>nil, "archived"=>false, "town"=>nil, "main"=>false, "created_at"=>nil}
>> a.attributes.each_pair { |attribute, value| a[attribute] = value.upcase if value.is_a?(String) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment