Skip to content

Commit 6008302

Browse files
committed
fix coercion of ShallowAttributes values
1 parent 37fe194 commit 6008302

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/shallow_attributes/instance_methods.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,13 @@ def reset_attribute(attribute)
139139
#
140140
# @since 0.1.0
141141
def coerce(value, _options = {})
142-
self.attributes = value
142+
self.attributes =
143+
if value.class.included_modules.include?(ShallowAttributes)
144+
value.to_h
145+
else
146+
value
147+
end
148+
143149
self
144150
end
145151

0 commit comments

Comments
 (0)