undefine_attribute_methods()
Instance Public methods
Removes all the previously dynamically defined methods from the class.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | class Person include ActiveModel::AttributeMethods attr_accessor :name attribute_method_suffix '_short?' define_attribute_method :name private def attribute_short?(attr) send(attr).length < 5 end end person = Person. new person.name = 'Bob' person.name_short? # => true Person.undefine_attribute_methods person.name_short? # => NoMethodError |
Please login to continue.