I'm trying to run the following but i keep getting a
"NoMethodError: undefined method `bar=' for #/Foo:0x86f69ba/"
class Class
def my_attr_accessor(name)
attr_name = name.to_s
attr_reader name
attr_reader "my_"+name
class_eval %Q"def #{name}=(val)
@#{name}=val
end"
end
end
I'm actually using something similar to this post: Ruby - Using class_eval to define methods
EDITED: you're quite right I made the change to reflect this.. thanks a lot.