Okay, I found a solution. It isn't very readable, but it works:

user = User.new(:login=> "foo", :password=>"bar")  # :password is not
a column in the db, but defined in the model using
"attr_accessor :password" (see initial post)
[:login, :password].each do |x|
    getter = x     # => :password
    setter = (x.to_s << "=").to_sym    # => :password=
    original_val = user.method(getter).call
    user.method(setter).call(some_new_val)
    do_some_test(user)
    user.method(setter).call(original_val)
end

Any clean up suggestion?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to