module ActiveModel::AttributeMethods::ClassMethods
def undefine_attribute_methods
Person.undefine_attribute_methods
person.name_short? # => true
person.name = 'Bob'
person = Person.new
end
end
send(attr).length < 5
def attribute_short?(attr)
private
define_attribute_method :name
attribute_method_suffix '_short?'
attr_accessor :name
include ActiveModel::AttributeMethods
class Person
Removes all the previously dynamically defined methods from the class.
def undefine_attribute_methods generated_attribute_methods.module_eval do undef_method(*instance_methods) end attribute_method_matchers_cache.clear end