Skip to content

Commit 1f3cfb2

Browse files
committed
Remove support to Marshal load Rails 5.x ActiveModel::AttributeSet format
1 parent 2996732 commit 1f3cfb2

File tree

4 files changed

+9
-20
lines changed

4 files changed

+9
-20
lines changed

activemodel/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
* Remove support to Marshal load Rails 5.x `ActiveModel::AttributeSet` format.
2+
3+
*Rafael Mendonça França*
4+
15
* Remove support to Marshal and YAML load Rails 5.x error format.
26

37
*Rafael Mendonça França*

activemodel/lib/active_model/attribute_set/builder.rb

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -144,16 +144,7 @@ def marshal_dump
144144
end
145145

146146
def marshal_load(values)
147-
if values.is_a?(Hash)
148-
ActiveSupport::Deprecation.warn(<<~MSG)
149-
Marshalling load from legacy attributes format is deprecated and will be removed in Rails 7.0.
150-
MSG
151-
empty_hash = {}.freeze
152-
initialize(empty_hash, empty_hash, empty_hash, empty_hash, values)
153-
@materialized = true
154-
else
155-
initialize(*values)
156-
end
147+
initialize(*values)
157148
end
158149

159150
protected

activemodel/test/cases/attribute_set_test.rb

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ def serialize(value)
232232
assert_equal({ foo: "1" }, attributes.to_hash)
233233
end
234234

235-
test "marshalling dump/load legacy materialized attribute hash" do
235+
test "marshalling dump/load materialized attribute hash" do
236236
builder = AttributeSet::Builder.new(foo: Type::String.new)
237237

238238
def builder.build_from_database(values = {}, additional_types = {})
@@ -242,16 +242,8 @@ def builder.build_from_database(values = {}, additional_types = {})
242242

243243
attributes = builder.build_from_database(foo: "1")
244244

245-
attributes.instance_variable_get(:@attributes).instance_eval do
246-
class << self
247-
def marshal_dump
248-
materialize # legacy marshal format before Rails 5.1
249-
end
250-
end
251-
end
252-
253245
data = Marshal.dump(attributes)
254-
attributes = assert_deprecated { Marshal.load(data) }
246+
attributes = Marshal.load(data)
255247
assert_equal({ foo: "1" }, attributes.to_hash)
256248
end
257249

guides/source/7_0_release_notes.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ Please refer to the [Changelog][active-model] for detailed changes.
144144

145145
* Remove support to Marshal and YAML load Rails 5.x error format.
146146

147+
* Remove support to Marshal load Rails 5.x `ActiveModel::AttributeSet` format.
148+
147149
### Deprecations
148150

149151
### Notable changes

0 commit comments

Comments
 (0)