method
type_cast_attribute
v3.2.8 -
Show latest stable
-
0 notes -
Class: ActiveRecord::AttributeMethods::Read::ClassMethods
- 1.0.0
- 1.1.6
- 1.2.6
- 2.0.3
- 2.1.0
- 2.2.1
- 2.3.8
- 3.0.0
- 3.0.9
- 3.1.0
- 3.2.1 (0)
- 3.2.8 (0)
- 3.2.13 (0)
- 4.0.2
- 4.1.8
- 4.2.1
- 4.2.7
- 4.2.9
- 5.0.0.1
- 5.1.7
- 5.2.3
- 6.0.0
- 6.1.3.1
- 6.1.7.7
- 7.0.0
- 7.1.3.2
- What's this?
type_cast_attribute(attr_name, attributes, cache = {})
public
Hide source
# File activerecord/lib/active_record/attribute_methods/read.rb, line 40 def type_cast_attribute(attr_name, attributes, cache = {}) #:nodoc: return unless attr_name attr_name = attr_name.to_s if generated_external_attribute_methods.method_defined?(attr_name) if attributes.has_key?(attr_name) || attr_name == 'id' generated_external_attribute_methods.send(attr_name, attributes[attr_name], attributes, cache, attr_name) end elsif !attribute_methods_generated? # If we haven't generated the caster methods yet, do that and # then try again define_attribute_methods type_cast_attribute(attr_name, attributes, cache) else # If we get here, the attribute has no associated DB column, so # just return it verbatim. attributes[attr_name] end end