active_type 2.4.1 → 2.5.1
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/.github/workflows/test.yml +9 -6
- data/.ruby-version +1 -1
- data/CHANGELOG.md +9 -0
- data/Gemfile.5.2.mysql2.lock +1 -1
- data/Gemfile.5.2.pg.lock +1 -1
- data/Gemfile.5.2.sqlite3.lock +1 -1
- data/Gemfile.6.0.sqlite3.lock +1 -1
- data/Gemfile.6.1.pg.lock +1 -1
- data/Gemfile.6.1.sqlite3.lock +1 -1
- data/Gemfile.7.0.pg.lock +1 -1
- data/Gemfile.7.0.sqlite3.lock +1 -1
- data/Gemfile.7.1.pg +9 -0
- data/Gemfile.7.1.pg.lock +68 -0
- data/Gemfile.7.1.sqlite3 +9 -0
- data/Gemfile.7.1.sqlite3.lock +70 -0
- data/Gemfile.7.2.pg +9 -0
- data/Gemfile.7.2.pg.lock +70 -0
- data/Gemfile.7.2.sqlite3 +9 -0
- data/Gemfile.7.2.sqlite3.lock +72 -0
- data/README.md +3 -2
- data/lib/active_type/no_table.rb +11 -0
- data/lib/active_type/util/unmutable_attributes.rb +4 -0
- data/lib/active_type/version.rb +1 -1
- data/lib/active_type/virtual_attributes.rb +7 -0
- data/lib/active_type.rb +4 -0
- metadata +11 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f243c433c673eb72dc622d9315f8a68a33b788a4f20cb82a5b480dc82ccb73b9
|
|
4
|
+
data.tar.gz: f8f6b146776a25cfbcbb3acf8c9fafa46c22e68136ed23a9a004a75af0cf6e05
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e4035273c367cb091908f5ad2db1949970e8e323b72629580a11e8309f48aa5ec4eb45e54a7e0c0896cf508c394ac6a0e72b51dc059a1b644751c400964f8319
|
|
7
|
+
data.tar.gz: 9b79ccb1b3bbdc6dd0ad6c0cec7254a5ed41f18d41020a5c774a021eb898fe721fe3c7918b73253ac88689c54a1430b74f56babc1f40aaad5a705ccf81e55424
|
data/.github/workflows/test.yml
CHANGED
|
@@ -28,6 +28,10 @@ jobs:
|
|
|
28
28
|
gemfile: Gemfile.7.0.sqlite3
|
|
29
29
|
- ruby: "3.2.0"
|
|
30
30
|
gemfile: Gemfile.7.0.sqlite3
|
|
31
|
+
- ruby: "3.2.0"
|
|
32
|
+
gemfile: Gemfile.7.1.sqlite3
|
|
33
|
+
- ruby: "3.2.0"
|
|
34
|
+
gemfile: Gemfile.7.2.sqlite3
|
|
31
35
|
env:
|
|
32
36
|
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
|
|
33
37
|
|
|
@@ -87,6 +91,7 @@ jobs:
|
|
|
87
91
|
image: postgres
|
|
88
92
|
env:
|
|
89
93
|
POSTGRES_PASSWORD: postgres
|
|
94
|
+
POSTGRES_DB: active_type_test
|
|
90
95
|
options: >-
|
|
91
96
|
--health-cmd pg_isready
|
|
92
97
|
--health-interval 10s
|
|
@@ -111,21 +116,19 @@ jobs:
|
|
|
111
116
|
gemfile: Gemfile.7.0.pg
|
|
112
117
|
- ruby: "3.2.0"
|
|
113
118
|
gemfile: Gemfile.7.0.pg
|
|
119
|
+
- ruby: "3.2.0"
|
|
120
|
+
gemfile: Gemfile.7.1.pg
|
|
121
|
+
- ruby: "3.2.0"
|
|
122
|
+
gemfile: Gemfile.7.2.pg
|
|
114
123
|
env:
|
|
115
124
|
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
|
|
116
125
|
|
|
117
126
|
steps:
|
|
118
127
|
- uses: actions/checkout@v3
|
|
119
|
-
- name: Install database client
|
|
120
|
-
run: |
|
|
121
|
-
sudo apt-get install -y postgresql-client
|
|
122
128
|
- name: Install ruby
|
|
123
129
|
uses: ruby/setup-ruby@v1
|
|
124
130
|
with:
|
|
125
131
|
ruby-version: ${{ matrix.ruby }}
|
|
126
132
|
bundler-cache: true
|
|
127
|
-
- name: Setup databases
|
|
128
|
-
run: |
|
|
129
|
-
PGPASSWORD=postgres psql -c 'create database active_type_test;' -U postgres -p 5432 -h localhost
|
|
130
133
|
- name: Run tests
|
|
131
134
|
run: bundle exec rake spec
|
data/.ruby-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
3.
|
|
1
|
+
3.2
|
data/CHANGELOG.md
CHANGED
|
@@ -2,11 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## 2.5.1 (2024-08-14)
|
|
6
|
+
|
|
7
|
+
* Fixed: Make `ActiveType::Object` work on Rails 7.2.
|
|
8
|
+
|
|
9
|
+
## 2.5.0 (2024-02-29)
|
|
10
|
+
|
|
11
|
+
* Passing unfrozen objects as a default for an attribute is deprecated, since these objects might be shared between records.
|
|
12
|
+
|
|
5
13
|
## 2.4.1 (2024-01-08)
|
|
6
14
|
|
|
7
15
|
* Fixed: Calling `#attributes` on the base record after a cast works now and does not throw a `MutationAfterCastError`
|
|
8
16
|
|
|
9
17
|
## 2.4.0 (2023-12-22)
|
|
18
|
+
|
|
10
19
|
* Added: You can implement an `#after_cast` that is called with the original record when calling `ActiveType.cast`.
|
|
11
20
|
Thanks to @MaximilianoGarciaRoe.
|
|
12
21
|
|
data/Gemfile.5.2.mysql2.lock
CHANGED
data/Gemfile.5.2.pg.lock
CHANGED
data/Gemfile.5.2.sqlite3.lock
CHANGED
data/Gemfile.6.0.sqlite3.lock
CHANGED
data/Gemfile.6.1.pg.lock
CHANGED
data/Gemfile.6.1.sqlite3.lock
CHANGED
data/Gemfile.7.0.pg.lock
CHANGED
data/Gemfile.7.0.sqlite3.lock
CHANGED
data/Gemfile.7.1.pg
ADDED
data/Gemfile.7.1.pg.lock
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
active_type (2.5.1)
|
|
5
|
+
activerecord (>= 3.2)
|
|
6
|
+
|
|
7
|
+
GEM
|
|
8
|
+
remote: https://rubygems.org/
|
|
9
|
+
specs:
|
|
10
|
+
activemodel (7.1.3.4)
|
|
11
|
+
activesupport (= 7.1.3.4)
|
|
12
|
+
activerecord (7.1.3.4)
|
|
13
|
+
activemodel (= 7.1.3.4)
|
|
14
|
+
activesupport (= 7.1.3.4)
|
|
15
|
+
timeout (>= 0.4.0)
|
|
16
|
+
activesupport (7.1.3.4)
|
|
17
|
+
base64
|
|
18
|
+
bigdecimal
|
|
19
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
20
|
+
connection_pool (>= 2.2.5)
|
|
21
|
+
drb
|
|
22
|
+
i18n (>= 1.6, < 2)
|
|
23
|
+
minitest (>= 5.1)
|
|
24
|
+
mutex_m
|
|
25
|
+
tzinfo (~> 2.0)
|
|
26
|
+
base64 (0.2.0)
|
|
27
|
+
bigdecimal (3.1.8)
|
|
28
|
+
concurrent-ruby (1.3.4)
|
|
29
|
+
connection_pool (2.4.1)
|
|
30
|
+
diff-lcs (1.5.1)
|
|
31
|
+
drb (2.2.1)
|
|
32
|
+
gemika (0.8.3)
|
|
33
|
+
i18n (1.14.5)
|
|
34
|
+
concurrent-ruby (~> 1.0)
|
|
35
|
+
minitest (5.24.1)
|
|
36
|
+
mutex_m (0.2.0)
|
|
37
|
+
pg (1.5.7)
|
|
38
|
+
rake (13.2.1)
|
|
39
|
+
rspec (3.13.0)
|
|
40
|
+
rspec-core (~> 3.13.0)
|
|
41
|
+
rspec-expectations (~> 3.13.0)
|
|
42
|
+
rspec-mocks (~> 3.13.0)
|
|
43
|
+
rspec-core (3.13.0)
|
|
44
|
+
rspec-support (~> 3.13.0)
|
|
45
|
+
rspec-expectations (3.13.1)
|
|
46
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
47
|
+
rspec-support (~> 3.13.0)
|
|
48
|
+
rspec-mocks (3.13.1)
|
|
49
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
50
|
+
rspec-support (~> 3.13.0)
|
|
51
|
+
rspec-support (3.13.1)
|
|
52
|
+
timeout (0.4.1)
|
|
53
|
+
tzinfo (2.0.6)
|
|
54
|
+
concurrent-ruby (~> 1.0)
|
|
55
|
+
|
|
56
|
+
PLATFORMS
|
|
57
|
+
ruby
|
|
58
|
+
|
|
59
|
+
DEPENDENCIES
|
|
60
|
+
active_type!
|
|
61
|
+
activerecord (~> 7.1.0)
|
|
62
|
+
gemika
|
|
63
|
+
pg
|
|
64
|
+
rake
|
|
65
|
+
rspec (~> 3.4)
|
|
66
|
+
|
|
67
|
+
BUNDLED WITH
|
|
68
|
+
2.5.6
|
data/Gemfile.7.1.sqlite3
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
active_type (2.5.1)
|
|
5
|
+
activerecord (>= 3.2)
|
|
6
|
+
|
|
7
|
+
GEM
|
|
8
|
+
remote: https://rubygems.org/
|
|
9
|
+
specs:
|
|
10
|
+
activemodel (7.1.3.4)
|
|
11
|
+
activesupport (= 7.1.3.4)
|
|
12
|
+
activerecord (7.1.3.4)
|
|
13
|
+
activemodel (= 7.1.3.4)
|
|
14
|
+
activesupport (= 7.1.3.4)
|
|
15
|
+
timeout (>= 0.4.0)
|
|
16
|
+
activesupport (7.1.3.4)
|
|
17
|
+
base64
|
|
18
|
+
bigdecimal
|
|
19
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
20
|
+
connection_pool (>= 2.2.5)
|
|
21
|
+
drb
|
|
22
|
+
i18n (>= 1.6, < 2)
|
|
23
|
+
minitest (>= 5.1)
|
|
24
|
+
mutex_m
|
|
25
|
+
tzinfo (~> 2.0)
|
|
26
|
+
base64 (0.2.0)
|
|
27
|
+
bigdecimal (3.1.8)
|
|
28
|
+
concurrent-ruby (1.3.4)
|
|
29
|
+
connection_pool (2.4.1)
|
|
30
|
+
diff-lcs (1.5.1)
|
|
31
|
+
drb (2.2.1)
|
|
32
|
+
gemika (0.8.3)
|
|
33
|
+
i18n (1.14.5)
|
|
34
|
+
concurrent-ruby (~> 1.0)
|
|
35
|
+
mini_portile2 (2.8.7)
|
|
36
|
+
minitest (5.24.1)
|
|
37
|
+
mutex_m (0.2.0)
|
|
38
|
+
rake (13.2.1)
|
|
39
|
+
rspec (3.13.0)
|
|
40
|
+
rspec-core (~> 3.13.0)
|
|
41
|
+
rspec-expectations (~> 3.13.0)
|
|
42
|
+
rspec-mocks (~> 3.13.0)
|
|
43
|
+
rspec-core (3.13.0)
|
|
44
|
+
rspec-support (~> 3.13.0)
|
|
45
|
+
rspec-expectations (3.13.1)
|
|
46
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
47
|
+
rspec-support (~> 3.13.0)
|
|
48
|
+
rspec-mocks (3.13.1)
|
|
49
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
50
|
+
rspec-support (~> 3.13.0)
|
|
51
|
+
rspec-support (3.13.1)
|
|
52
|
+
sqlite3 (1.6.0)
|
|
53
|
+
mini_portile2 (~> 2.8.0)
|
|
54
|
+
timeout (0.4.1)
|
|
55
|
+
tzinfo (2.0.6)
|
|
56
|
+
concurrent-ruby (~> 1.0)
|
|
57
|
+
|
|
58
|
+
PLATFORMS
|
|
59
|
+
ruby
|
|
60
|
+
|
|
61
|
+
DEPENDENCIES
|
|
62
|
+
active_type!
|
|
63
|
+
activerecord (~> 7.1.0)
|
|
64
|
+
gemika
|
|
65
|
+
rake
|
|
66
|
+
rspec (~> 3.4)
|
|
67
|
+
sqlite3 (= 1.6.0)
|
|
68
|
+
|
|
69
|
+
BUNDLED WITH
|
|
70
|
+
2.5.6
|
data/Gemfile.7.2.pg
ADDED
data/Gemfile.7.2.pg.lock
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
active_type (2.5.1)
|
|
5
|
+
activerecord (>= 3.2)
|
|
6
|
+
|
|
7
|
+
GEM
|
|
8
|
+
remote: https://rubygems.org/
|
|
9
|
+
specs:
|
|
10
|
+
activemodel (7.2.0)
|
|
11
|
+
activesupport (= 7.2.0)
|
|
12
|
+
activerecord (7.2.0)
|
|
13
|
+
activemodel (= 7.2.0)
|
|
14
|
+
activesupport (= 7.2.0)
|
|
15
|
+
timeout (>= 0.4.0)
|
|
16
|
+
activesupport (7.2.0)
|
|
17
|
+
base64
|
|
18
|
+
bigdecimal
|
|
19
|
+
concurrent-ruby (~> 1.0, >= 1.3.1)
|
|
20
|
+
connection_pool (>= 2.2.5)
|
|
21
|
+
drb
|
|
22
|
+
i18n (>= 1.6, < 2)
|
|
23
|
+
logger (>= 1.4.2)
|
|
24
|
+
minitest (>= 5.1)
|
|
25
|
+
securerandom (>= 0.3)
|
|
26
|
+
tzinfo (~> 2.0, >= 2.0.5)
|
|
27
|
+
base64 (0.2.0)
|
|
28
|
+
bigdecimal (3.1.8)
|
|
29
|
+
concurrent-ruby (1.3.4)
|
|
30
|
+
connection_pool (2.4.1)
|
|
31
|
+
diff-lcs (1.5.1)
|
|
32
|
+
drb (2.2.1)
|
|
33
|
+
gemika (0.8.3)
|
|
34
|
+
i18n (1.14.5)
|
|
35
|
+
concurrent-ruby (~> 1.0)
|
|
36
|
+
logger (1.6.0)
|
|
37
|
+
minitest (5.24.1)
|
|
38
|
+
pg (1.5.7)
|
|
39
|
+
rake (13.2.1)
|
|
40
|
+
rspec (3.13.0)
|
|
41
|
+
rspec-core (~> 3.13.0)
|
|
42
|
+
rspec-expectations (~> 3.13.0)
|
|
43
|
+
rspec-mocks (~> 3.13.0)
|
|
44
|
+
rspec-core (3.13.0)
|
|
45
|
+
rspec-support (~> 3.13.0)
|
|
46
|
+
rspec-expectations (3.13.1)
|
|
47
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
48
|
+
rspec-support (~> 3.13.0)
|
|
49
|
+
rspec-mocks (3.13.1)
|
|
50
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
51
|
+
rspec-support (~> 3.13.0)
|
|
52
|
+
rspec-support (3.13.1)
|
|
53
|
+
securerandom (0.3.1)
|
|
54
|
+
timeout (0.4.1)
|
|
55
|
+
tzinfo (2.0.6)
|
|
56
|
+
concurrent-ruby (~> 1.0)
|
|
57
|
+
|
|
58
|
+
PLATFORMS
|
|
59
|
+
ruby
|
|
60
|
+
|
|
61
|
+
DEPENDENCIES
|
|
62
|
+
active_type!
|
|
63
|
+
activerecord (~> 7.2.0)
|
|
64
|
+
gemika
|
|
65
|
+
pg
|
|
66
|
+
rake
|
|
67
|
+
rspec (~> 3.4)
|
|
68
|
+
|
|
69
|
+
BUNDLED WITH
|
|
70
|
+
2.5.6
|
data/Gemfile.7.2.sqlite3
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
active_type (2.5.1)
|
|
5
|
+
activerecord (>= 3.2)
|
|
6
|
+
|
|
7
|
+
GEM
|
|
8
|
+
remote: https://rubygems.org/
|
|
9
|
+
specs:
|
|
10
|
+
activemodel (7.2.0)
|
|
11
|
+
activesupport (= 7.2.0)
|
|
12
|
+
activerecord (7.2.0)
|
|
13
|
+
activemodel (= 7.2.0)
|
|
14
|
+
activesupport (= 7.2.0)
|
|
15
|
+
timeout (>= 0.4.0)
|
|
16
|
+
activesupport (7.2.0)
|
|
17
|
+
base64
|
|
18
|
+
bigdecimal
|
|
19
|
+
concurrent-ruby (~> 1.0, >= 1.3.1)
|
|
20
|
+
connection_pool (>= 2.2.5)
|
|
21
|
+
drb
|
|
22
|
+
i18n (>= 1.6, < 2)
|
|
23
|
+
logger (>= 1.4.2)
|
|
24
|
+
minitest (>= 5.1)
|
|
25
|
+
securerandom (>= 0.3)
|
|
26
|
+
tzinfo (~> 2.0, >= 2.0.5)
|
|
27
|
+
base64 (0.2.0)
|
|
28
|
+
bigdecimal (3.1.8)
|
|
29
|
+
concurrent-ruby (1.3.4)
|
|
30
|
+
connection_pool (2.4.1)
|
|
31
|
+
diff-lcs (1.5.1)
|
|
32
|
+
drb (2.2.1)
|
|
33
|
+
gemika (0.8.3)
|
|
34
|
+
i18n (1.14.5)
|
|
35
|
+
concurrent-ruby (~> 1.0)
|
|
36
|
+
logger (1.6.0)
|
|
37
|
+
mini_portile2 (2.8.7)
|
|
38
|
+
minitest (5.24.1)
|
|
39
|
+
rake (13.2.1)
|
|
40
|
+
rspec (3.13.0)
|
|
41
|
+
rspec-core (~> 3.13.0)
|
|
42
|
+
rspec-expectations (~> 3.13.0)
|
|
43
|
+
rspec-mocks (~> 3.13.0)
|
|
44
|
+
rspec-core (3.13.0)
|
|
45
|
+
rspec-support (~> 3.13.0)
|
|
46
|
+
rspec-expectations (3.13.1)
|
|
47
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
48
|
+
rspec-support (~> 3.13.0)
|
|
49
|
+
rspec-mocks (3.13.1)
|
|
50
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
51
|
+
rspec-support (~> 3.13.0)
|
|
52
|
+
rspec-support (3.13.1)
|
|
53
|
+
securerandom (0.3.1)
|
|
54
|
+
sqlite3 (1.6.0)
|
|
55
|
+
mini_portile2 (~> 2.8.0)
|
|
56
|
+
timeout (0.4.1)
|
|
57
|
+
tzinfo (2.0.6)
|
|
58
|
+
concurrent-ruby (~> 1.0)
|
|
59
|
+
|
|
60
|
+
PLATFORMS
|
|
61
|
+
ruby
|
|
62
|
+
|
|
63
|
+
DEPENDENCIES
|
|
64
|
+
active_type!
|
|
65
|
+
activerecord (~> 7.2.0)
|
|
66
|
+
gemika
|
|
67
|
+
rake
|
|
68
|
+
rspec (~> 3.4)
|
|
69
|
+
sqlite3 (= 1.6.0)
|
|
70
|
+
|
|
71
|
+
BUNDLED WITH
|
|
72
|
+
2.5.6
|
data/README.md
CHANGED
|
@@ -381,12 +381,13 @@ sign_up.is_a?(SignUp) # => true
|
|
|
381
381
|
|
|
382
382
|
If you need to add some special logic after casting you can add an `after_cast` method:
|
|
383
383
|
|
|
384
|
+
```ruby
|
|
384
385
|
class SignUp < ActiveType::Record[User]
|
|
385
386
|
def after_cast(user)
|
|
386
387
|
# Called with the original user upon casting.
|
|
387
388
|
end
|
|
388
389
|
end
|
|
389
|
-
|
|
390
|
+
```
|
|
390
391
|
|
|
391
392
|
|
|
392
393
|
Associations
|
|
@@ -395,7 +396,7 @@ Associations
|
|
|
395
396
|
Sometimes, you have an association, and a form model for that association. Instead of always casting the associations manually, you can use the `change_association` macro to override an association's options. For example.
|
|
396
397
|
|
|
397
398
|
|
|
398
|
-
```
|
|
399
|
+
```ruby
|
|
399
400
|
class Credential < ActiveRecord::Base
|
|
400
401
|
end
|
|
401
402
|
|
data/lib/active_type/no_table.rb
CHANGED
|
@@ -132,6 +132,10 @@ module ActiveType
|
|
|
132
132
|
@connection ||= DummyConnection.new(nil)
|
|
133
133
|
end
|
|
134
134
|
|
|
135
|
+
def with_connection(**)
|
|
136
|
+
yield(connection)
|
|
137
|
+
end
|
|
138
|
+
|
|
135
139
|
def destroy(*)
|
|
136
140
|
new
|
|
137
141
|
end
|
|
@@ -148,6 +152,13 @@ module ActiveType
|
|
|
148
152
|
[]
|
|
149
153
|
end
|
|
150
154
|
|
|
155
|
+
def cached_find_by(*)
|
|
156
|
+
nil
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
def schema_cache
|
|
160
|
+
DummySchemaCache.new
|
|
161
|
+
end
|
|
151
162
|
end
|
|
152
163
|
|
|
153
164
|
def destroy
|
|
@@ -28,6 +28,10 @@ module ActiveType
|
|
|
28
28
|
original_attributes.key?(key)
|
|
29
29
|
end
|
|
30
30
|
|
|
31
|
+
def keys
|
|
32
|
+
original_attributes.keys
|
|
33
|
+
end
|
|
34
|
+
|
|
31
35
|
def method_missing(*args)
|
|
32
36
|
raise MutationAfterCastError, 'Changing a record that has been used to create an ActiveType::Record could have unexpected side effects!'
|
|
33
37
|
end
|
data/lib/active_type/version.rb
CHANGED
|
@@ -54,6 +54,7 @@ module ActiveType
|
|
|
54
54
|
def build(name, type, options)
|
|
55
55
|
validate_attribute_name!(name)
|
|
56
56
|
options.assert_valid_keys(:default)
|
|
57
|
+
deprecate_non_frozen_defaults(options[:default], name)
|
|
57
58
|
add_virtual_column(name, type, options)
|
|
58
59
|
build_reader(name)
|
|
59
60
|
build_writer(name)
|
|
@@ -68,6 +69,12 @@ module ActiveType
|
|
|
68
69
|
@owner.virtual_columns_hash = @owner.virtual_columns_hash.merge(name.to_s => column)
|
|
69
70
|
end
|
|
70
71
|
|
|
72
|
+
def deprecate_non_frozen_defaults(default, name)
|
|
73
|
+
unless default.respond_to?(:call) || default.frozen?
|
|
74
|
+
ActiveType.deprecator.warn("##{name}: Passing a non-frozen object as a default is deprecated. Mutating the attribute can change the default for other records. You can also wrap it in a proc.", caller_locations(3))
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
71
78
|
def build_reader(name)
|
|
72
79
|
@module.module_eval <<-BODY, __FILE__, __LINE__ + 1
|
|
73
80
|
def #{name}
|
data/lib/active_type.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: active_type
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.5.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tobias Kraze
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2024-
|
|
12
|
+
date: 2024-08-14 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: bundler
|
|
@@ -81,6 +81,14 @@ files:
|
|
|
81
81
|
- Gemfile.7.0.pg.lock
|
|
82
82
|
- Gemfile.7.0.sqlite3
|
|
83
83
|
- Gemfile.7.0.sqlite3.lock
|
|
84
|
+
- Gemfile.7.1.pg
|
|
85
|
+
- Gemfile.7.1.pg.lock
|
|
86
|
+
- Gemfile.7.1.sqlite3
|
|
87
|
+
- Gemfile.7.1.sqlite3.lock
|
|
88
|
+
- Gemfile.7.2.pg
|
|
89
|
+
- Gemfile.7.2.pg.lock
|
|
90
|
+
- Gemfile.7.2.sqlite3
|
|
91
|
+
- Gemfile.7.2.sqlite3.lock
|
|
84
92
|
- Gemfile.lock
|
|
85
93
|
- LICENSE
|
|
86
94
|
- README.md
|
|
@@ -128,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
128
136
|
- !ruby/object:Gem::Version
|
|
129
137
|
version: '0'
|
|
130
138
|
requirements: []
|
|
131
|
-
rubygems_version: 3.
|
|
139
|
+
rubygems_version: 3.4.10
|
|
132
140
|
signing_key:
|
|
133
141
|
specification_version: 4
|
|
134
142
|
summary: Make any Ruby object quack like ActiveRecord
|