instance method
read_attribute
Ruby on Rails edge
Since v3.0.20Signature
read_attribute(attr_name, &block)
Returns the value of the attribute identified by attr_name after it has been type cast. For example, a date attribute will cast “2004-12-12” to ‘Date.new(2004, 12, 12)`. (For information about specific type casting behavior, see the types under ActiveModel::Type.)
Parameters
-
attr_namereq -
blockblock
Source
# File activerecord/lib/active_record/attribute_methods/read.rb, line 34
def read_attribute(attr_name, &block)
name = resolve_alias(attr_name.is_a?(Symbol) ? attr_name.name : attr_name.to_s)
@attributes.fetch_value(name, &block)
end
Defined in activerecord/lib/active_record/attribute_methods/read.rb line 34
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::AttributeMethods::Read