I have the following problem:
I am renaming all instance methods for a specific class, using alias_method_chain in order to give them extra behavior. I get all instance methods with the following line of code:
self.class.instance_methods(false)
By doing that I get all my instance methods, but I also get the gettes and setters that I defined using attr_accessor / attr_reader / attr_writer.
What I need to do, is detect which methods returned from the previous line of code are accessor methods because I don’t want to rename those.
Obviusly, I can detect if the method name has a “=” at the end, that would make it a setter, and if that exists, I can see if the getter is defined aswell, but what happens when there is only a getter defined? How can I check that? Specially considering that the attributes are not available for the class method “instance_variables” until they’re initialized?
Thanks for the help!
You may extend attr_reader… to store the methods.
Result: