123456789_123456789_123456789_123456789_123456789_

Module: ActiveRecord::AttributeMethods::Read::ClassMethods

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

Instance Method Summary

Instance Method Details

#define_method_attribute(name, owner:) (private)

[ GitHub ]

  
# File 'activerecord/lib/active_record/attribute_methods/read.rb', line 11

def define_method_attribute(name, owner:)
  ActiveModel::AttributeMethods::AttrNames.define_attribute_accessor_method(
    owner, name
  ) do |temp_method_name, attr_name_expr|
    owner.define_cached_method(name, as: temp_method_name, namespace: :active_record) do |batch|
      batch <<
        "def #{temp_method_name}" <<
        "  _read_attribute(#{attr_name_expr}) { |n| missing_attribute(n, caller) }" <<
        "end"
    end
  end
end