method
define_method_attribute
v8.0.0 -
Show latest stable
- Class:
ActiveRecord::AttributeMethods::Read::ClassMethods
define_method_attribute(canonical_name, owner:, as: canonical_name)private
No documentation available.
# File activerecord/lib/active_record/attribute_methods/read.rb, line 11
def define_method_attribute(canonical_name, owner,, as: canonical_name)
ActiveModel::AttributeMethods::AttrNames.define_attribute_accessor_method(
owner, canonical_name
) 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}" <<
" _read_attribute(#{attr_name_expr}) { |n| missing_attribute(n, caller) }" <<
"end"
end
end
end