123456789_123456789_123456789_123456789_123456789_

Module: ActiveRecord::AttributeMethods::Write::ClassMethods

Do not use. This module is for internal use only.
Relationships & Source Files
Defined in: activerecord/lib/active_record/attribute_methods/write.rb

Instance Method Summary

Instance Method Details

#define_method_attribute=(canonical_name, owner:, as: canonical_name) (private)

[ GitHub ]

  
# File 'activerecord/lib/active_record/attribute_methods/write.rb', line 15

def define_method_attribute=(canonical_name, owner:, as: canonical_name)
  ActiveModel::AttributeMethods::AttrNames.define_attribute_accessor_method(
    owner, canonical_name, writer: true,
  ) do |temp_method_name, attr_name_expr|
    owner.define_cached_method(temp_method_name, as: "#{as}=", namespace: :active_record) do |batch|
      batch <<
        "def #{temp_method_name}(value)" <<
        "  _write_attribute(#{attr_name_expr}, value)" <<
        "end"
    end
  end
end