module ActiveModel::AttributeMethods::ClassMethods
def define_attribute_methods(*attr_names)
end
send("#{attr}=", nil)
def clear_attribute(attr)
private
define_attribute_methods :name, :age, :address
# attribute_method_affix declarations.
# attribute_method_prefix, attribute_method_suffix or
# Call to define_attribute_methods must appear after the
attribute_method_prefix 'clear_'
attr_accessor :name, :age, :address
include ActiveModel::AttributeMethods
class Person
methods, or they will not hook in.
+define_attribute_methods+ after you define any prefix, suffix, or affix
To use, pass attribute names (as strings or symbols). Be sure to declare
ActiveModel::AttributeMethods.
Declares the attributes that should be prefixed and suffixed by
def define_attribute_methods(*attr_names) ActiveSupport::CodeGenerator.batch(generated_attribute_methods, __FILE__, __LINE__) do |owner| attr_names.flatten.each { |attr_name| define_attribute_method(attr_name, _owner: owner) } end end