From: Jan Svitok Date: 2006-09-02T08:43:01+09:00 Subject: Re: How can I do this without eval... On 9/2/06, J2M wrote: > def load_default_attributes(model_name, options = {}) > fixture = options[:fixture] || :default > attributes = temp_attributes = model = {} > instance_eval <<-FIN > temp_attributes = #{model_name.to_s.pluralize}("#{fixture}") > model = #{model_name.to_s.capitalize} > FIN Hi, model = const_get(model_name.to_s.capitalize) Classes are constants. So you can get them by name (string or symbol) with Module#const_get temp_attributes... I don't know what fixtures are, I'll just say that you can - call a method with Object#send(name, arg1, arg2) or send(name, *args) - get/set instance variable with instance_variable_get/instance_variable_set (don't forget the @! my_object.instance_variable_get('@name') ) - class variables with Module#class_variable_get/.._set and generally, look into Module, Class, Object and Kernel for other useful methods ;-) finally http://www.rubycentral.com/book/ospace.html can be helpful.