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
- #resolve_alias(attr_name)
-
#define_method_attribute(canonical_name, owner:, as: canonical_name)
private
: (String, owner:
::ActiveSupport::CodeGenerator, ?as:::String) -> void.
Instance Method Details
#define_method_attribute(canonical_name, owner:, as: canonical_name) (private)
: (String, owner: ::ActiveSupport::CodeGenerator, ?as: ::String) -> void
# File 'activerecord/lib/active_record/attribute_methods/read.rb', line 17
def define_method_attribute(canonical_name, owner:, as: canonical_name) slot = attributes_builder.indexes[canonical_name] unless slot raise ArgumentError, "#{self.name} has no attribute `#{canonical_name}` to define a reader for" end ActiveModel::AttributeMethods::AttrNames.define_attribute_accessor_method( "_read_attribute_#{slot}" ) do |temp_method_name| owner.define_cached_method(temp_method_name, as: as, namespace: :active_record_slot) do |batch| batch << "def #{temp_method_name}" << " _read_attribute_at!(#{slot})" << "end" end end end
#resolve_alias(attr_name)
[ GitHub ]# File 'activerecord/lib/active_record/attribute_methods/read.rb', line 11
def resolve_alias(attr_name) # :nodoc: attribute_aliases[attr_name] || attr_name end