aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/attribute_methods/read.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib/active_record/attribute_methods/read.rb')
-rw-r--r--activerecord/lib/active_record/attribute_methods/read.rb20
1 files changed, 10 insertions, 10 deletions
diff --git a/activerecord/lib/active_record/attribute_methods/read.rb b/activerecord/lib/active_record/attribute_methods/read.rb
index 788d671ad1..4fdfe77bab 100644
--- a/activerecord/lib/active_record/attribute_methods/read.rb
+++ b/activerecord/lib/active_record/attribute_methods/read.rb
@@ -91,21 +91,21 @@ module ActiveRecord
def _read_attribute(attr_name)
attr_name = attr_name.to_s
attr_name = self.class.primary_key if attr_name == 'id'
- value = @attributes[attr_name]
- unless value.nil?
- if column = column_for_attribute(attr_name)
- type_cast_attribute(column)
+
+ unless @attributes[attr_name].nil?
+ type_cast_attribute(column_for_attribute(attr_name), @attributes[attr_name])
+ end
+ end
+
+ private
+ def type_cast_attribute(column, value)
+ if column
+ column.type_cast(value)
else
value
end
end
- end
-
- def type_cast_attribute(column) #:nodoc:
- column.type_cast(@attributes[column.name])
- end
- private
def attribute(attribute_name)
read_attribute(attribute_name)
end