What\'s the shortest, one-liner way to list all methods defined with attr_accessor? I would like to make it so, if I have a class MyBaseClass, any
attr_accessor
MyBaseClass
It could be filtered with the equal sign matching logic:
methods = (SubClass.instance_methods - SubClass.superclass.instance_methods).map(&:to_s) methods.select { |method| !method.end_with?('=') && methods.include?(method + '=') } #> ["id", "title", "body"]