In general, how can I get a reference to an object whose name I have in a string?
More specifically, I have a list of the parameter names (the member variables - built dynamically so I can't refer to them directly).
Each parameter is an object that also has an from_s
method.
I want to do something like the following (which of course doesn't work...):
define_method(:from_s) do | arg |
@ordered_parameter_names.each do | param |
instance_eval "field_ref = @#{param}"
field_ref.from_s(param)
end
end