active_type 2.6.4 → 2.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.6.1.pg.lock +1 -1
- data/Gemfile.6.1.sqlite3.lock +1 -1
- data/Gemfile.7.1.pg.lock +1 -1
- data/Gemfile.7.1.sqlite3.lock +1 -1
- data/Gemfile.7.2.mysql2.lock +1 -1
- data/Gemfile.7.2.pg.lock +1 -1
- data/Gemfile.7.2.sqlite3.lock +1 -1
- data/Gemfile.8.0.sqlite3.lock +1 -1
- data/lib/active_type/marshalling.rb +62 -0
- data/lib/active_type/object.rb +2 -0
- data/lib/active_type/record.rb +2 -0
- data/lib/active_type/version.rb +1 -1
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39d607fc50012b8348c3536df88b78c30bcadaf6c01deb45fdca664b240061b5
|
4
|
+
data.tar.gz: 554cc69f58a1bf21ece2ad1b5246559f937abd44e6dc4eb5aea5abfb212fbf9a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68442050e7771c3e6a5889eda945635a4a9be009657692bdc43918815119d911b46c507d93e31142f46555c5b43ffe6b5b6ebe34b0a25336f10e953fe8e51e97
|
7
|
+
data.tar.gz: a126fbbfe0b5741ef6d49a641d907dd3857971ad3938f234778e375c0bc0e6d46cae23125f6eb36aea1c4fab1ba25d21579ceef22b21f1117ae6fa25ea3028cb
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
|
5
|
+
## 2.6.5 (2025-10-16)
|
6
|
+
|
7
|
+
* Fixed: ActiveType::Object and ActiveType::Record are now serialized/deserialized correctly using Marshal.dump/Marshal.load
|
8
|
+
|
5
9
|
## 2.6.4 (2025-09-11)
|
6
10
|
|
7
11
|
* Fixed: When using nests_many, nested updates, with preloaded records, using string ids will no longer cause additional DB queries.
|
data/Gemfile.6.1.pg.lock
CHANGED
data/Gemfile.6.1.sqlite3.lock
CHANGED
data/Gemfile.7.1.pg.lock
CHANGED
data/Gemfile.7.1.sqlite3.lock
CHANGED
data/Gemfile.7.2.mysql2.lock
CHANGED
data/Gemfile.7.2.pg.lock
CHANGED
data/Gemfile.7.2.sqlite3.lock
CHANGED
data/Gemfile.8.0.sqlite3.lock
CHANGED
@@ -0,0 +1,62 @@
|
|
1
|
+
module ActiveType
|
2
|
+
module Marshalling
|
3
|
+
# With 7.1 rails defines its own marshal_dump and marshal_load methods,
|
4
|
+
# which selectively only dump and load the record´s attributes and some more stuff, but not our @virtual_attributes.
|
5
|
+
# Whether these new methods are actually used, depends on ActiveRecord::Marshalling.format_version
|
6
|
+
# For format_version = 6.1 active record uses the default ruby implementation for dumping and loading.
|
7
|
+
# For format_version = 7.1 active record uses a custom implementation, which we need to override.
|
8
|
+
#
|
9
|
+
# format_version can also be dynamically changed during runtime, on change we need to define or undefine our marshal_dump dynamically, because:
|
10
|
+
# * We cannot check the format_version at runtime within marshal_dump or marshal_load,
|
11
|
+
# as we can´t just super to the default for the wrong version, because there is no method to super to.
|
12
|
+
# (The default implementation is a ruby internal, not a real method.)
|
13
|
+
# * We cannot override the methods at load time only when format version is 7.1,
|
14
|
+
# because format version usually gets set after our initialisation and could change at any time.
|
15
|
+
#
|
16
|
+
# Two facts about ruby also help us with that (also see https://ruby-doc.org/core-2.6.8/Marshal.html):
|
17
|
+
# * A custom marshal_load is only used, when marshal_dump is also defined. So we can keep marshal_dump always defined.
|
18
|
+
# (If either is missing, ruby will use _dump and _load)
|
19
|
+
# * If a serialized object is dumped using _dump it will be loaded using _load, never marshal_load, so a record
|
20
|
+
# serialized with format_version = 6.1 using _dump, will always load using _load, ignoring whether marshal_load is defined or not.
|
21
|
+
# This ensures objects will always be deserialized with the method they were serialized with. We don´t need to worry about that.
|
22
|
+
|
23
|
+
class << self
|
24
|
+
attr_reader :format_version
|
25
|
+
|
26
|
+
def format_version=(version)
|
27
|
+
case version
|
28
|
+
when 6.1
|
29
|
+
Methods.remove_method(:marshal_dump) if Methods.method_defined?(:marshal_dump)
|
30
|
+
when 7.1
|
31
|
+
Methods.alias_method(:marshal_dump, :_marshal_dump_7_1)
|
32
|
+
else
|
33
|
+
raise ArgumentError, "Unknown marshalling format: #{version.inspect}"
|
34
|
+
end
|
35
|
+
@format_version = version
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
module ActiveRecordMarshallingExtension
|
40
|
+
def format_version=(version)
|
41
|
+
ActiveType::Marshalling.format_version = version
|
42
|
+
super(version)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
module Methods
|
47
|
+
def _marshal_dump_7_1
|
48
|
+
[super, @virtual_attributes]
|
49
|
+
end
|
50
|
+
|
51
|
+
def marshal_load(state)
|
52
|
+
super_attributes, @virtual_attributes = state
|
53
|
+
super(super_attributes)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
ActiveRecord::Marshalling.singleton_class.prepend(ActiveType::Marshalling::ActiveRecordMarshallingExtension)
|
61
|
+
# Set ActiveType´s format_version to ActiveRecord´s, in case ActiveRecord uses the default value, which is set before we are loaded.
|
62
|
+
ActiveType::Marshalling.format_version = ActiveRecord::Marshalling.format_version
|
data/lib/active_type/object.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'active_type/no_table'
|
2
2
|
require 'active_type/virtual_attributes'
|
3
3
|
require 'active_type/nested_attributes'
|
4
|
+
require 'active_type/marshalling' if ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR >= 1
|
4
5
|
|
5
6
|
module ActiveType
|
6
7
|
|
@@ -9,6 +10,7 @@ module ActiveType
|
|
9
10
|
include NoTable
|
10
11
|
include VirtualAttributes
|
11
12
|
include NestedAttributes
|
13
|
+
include Marshalling::Methods if ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR >= 1
|
12
14
|
|
13
15
|
end
|
14
16
|
|
data/lib/active_type/record.rb
CHANGED
@@ -2,6 +2,7 @@ require 'active_type/virtual_attributes'
|
|
2
2
|
require 'active_type/record_extension'
|
3
3
|
require 'active_type/nested_attributes'
|
4
4
|
require 'active_type/change_association'
|
5
|
+
require 'active_type/marshalling' if ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR >= 1
|
5
6
|
|
6
7
|
module ActiveType
|
7
8
|
|
@@ -13,6 +14,7 @@ module ActiveType
|
|
13
14
|
include NestedAttributes
|
14
15
|
include RecordExtension
|
15
16
|
include ChangeAssociation
|
17
|
+
include Marshalling::Methods if ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR >= 1
|
16
18
|
|
17
19
|
end
|
18
20
|
|
data/lib/active_type/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_type
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.6.
|
4
|
+
version: 2.6.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tobias Kraze
|
8
8
|
- Henning Koch
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2025-
|
12
|
+
date: 2025-10-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -88,6 +88,7 @@ files:
|
|
88
88
|
- active_type.gemspec
|
89
89
|
- lib/active_type.rb
|
90
90
|
- lib/active_type/change_association.rb
|
91
|
+
- lib/active_type/marshalling.rb
|
91
92
|
- lib/active_type/mutation_after_cast_error.rb
|
92
93
|
- lib/active_type/nested_attributes.rb
|
93
94
|
- lib/active_type/nested_attributes/association.rb
|
@@ -119,7 +120,7 @@ metadata:
|
|
119
120
|
bug_tracker_uri: https://github.com/makandra/active_type/issues
|
120
121
|
changelog_uri: https://github.com/makandra/active_type/blob/master/CHANGELOG.md
|
121
122
|
rubygems_mfa_required: 'true'
|
122
|
-
post_install_message:
|
123
|
+
post_install_message:
|
123
124
|
rdoc_options: []
|
124
125
|
require_paths:
|
125
126
|
- lib
|
@@ -135,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
136
|
version: '0'
|
136
137
|
requirements: []
|
137
138
|
rubygems_version: 3.4.10
|
138
|
-
signing_key:
|
139
|
+
signing_key:
|
139
140
|
specification_version: 4
|
140
141
|
summary: Make any Ruby object quack like ActiveRecord
|
141
142
|
test_files: []
|