Skip to content

Commit 795324a

Browse files
MONGOID-4726 MONGOID-2951 Add code comment for related methods Mongoid::Fields.create_field_getter and Mongoid::Attributes#read_attribute (#5312)
Co-authored-by: shields <[email protected]>
1 parent 306b019 commit 795324a

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

lib/mongoid/attributes.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ def has_attribute_before_type_cast?(name)
8686
def read_attribute(name)
8787
field = fields[name.to_s]
8888
raw = read_raw_attribute(name)
89+
# Keep this code consistent with Mongoid::Fields.create_field_getter
8990
value = field ? field.demongoize(raw) : raw
9091
attribute_will_change!(name.to_s) if value.resizable?
9192
value

lib/mongoid/fields.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,7 @@ def create_field_getter(name, meth, field)
636636
if lazy_settable?(field, raw)
637637
write_attribute(name, field.eval_default(self))
638638
else
639+
# Keep this code consistent with Mongoid::Attributes#read_attribute
639640
value = field.demongoize(raw)
640641
attribute_will_change!(name) if value.resizable?
641642
value

0 commit comments

Comments
 (0)