instance method
undefine_attribute_methods
Ruby on Rails 4.2.9
Since v3.0.20Signature
undefine_attribute_methods()
Removes all the previously dynamically defined methods from the class.
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
Source
# File activemodel/lib/active_model/attribute_methods.rb, line 324
def undefine_attribute_methods
generated_attribute_methods.module_eval do
instance_methods.each { |m| undef_method(m) }
end
attribute_method_matchers_cache.clear
end
Defined in activemodel/lib/active_model/attribute_methods.rb line 324
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveModel::AttributeMethods::ClassMethods