active_type 1.4.2 → 1.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +175 -0
- data/CHANGELOG.md +25 -0
- data/Gemfile +1 -1
- data/Gemfile.3.2.mysql2 +1 -1
- data/Gemfile.3.2.mysql2.lock +10 -4
- data/Gemfile.3.2.sqlite3.lock +2 -2
- data/Gemfile.4.2.mysql2 +1 -1
- data/Gemfile.4.2.mysql2.lock +4 -4
- data/Gemfile.4.2.pg.lock +2 -2
- data/Gemfile.4.2.sqlite3.lock +2 -2
- data/Gemfile.5.2.mysql2.lock +27 -27
- data/Gemfile.5.2.pg.lock +27 -27
- data/Gemfile.5.2.sqlite3.lock +27 -27
- data/{Gemfile.6.0.pg → Gemfile.6.0.sqlite3} +1 -1
- data/Gemfile.6.0.sqlite3.lock +59 -0
- data/Gemfile.6.1.pg +9 -0
- data/Gemfile.6.1.pg.lock +58 -0
- data/Gemfile.6.1.sqlite3 +9 -0
- data/Gemfile.6.1.sqlite3.lock +58 -0
- data/Gemfile.lock +1 -1
- data/README.md +20 -6
- data/Rakefile +1 -1
- data/lib/active_type/change_association.rb +2 -2
- data/lib/active_type/nested_attributes/association.rb +19 -7
- data/lib/active_type/record_extension/inheritance.rb +20 -10
- data/lib/active_type/util.rb +3 -0
- data/lib/active_type/version.rb +1 -1
- data/lib/active_type/virtual_attributes.rb +26 -3
- metadata +10 -6
- data/.travis.yml +0 -72
- data/Gemfile.6.0.pg.lock +0 -59
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 21de85e1b19fed7dd547f3301c82ec967997b7fed1d8b063b674e15f538bcc49
|
4
|
+
data.tar.gz: 3e8b54eb5b1573b0d3284e7f6c216099d165b44c485f8881226a99447d78c18a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 04dc0427781f01314b7535b97bca3d002489ec9db45e6231e428e050d732c80d70ef07a1300e4dc8ba306aa3e3ea55ab124a7b6245c1928ed0909b24df798d2d
|
7
|
+
data.tar.gz: ebd393afc5b781ef4fd2edb3951b6d7c50ba691687c2c0a52ec76fbe013b9756776e61f4a655d3ce6221ed148c8aefff9d1cf770d95669f98102069affa67b72
|
@@ -0,0 +1,175 @@
|
|
1
|
+
name: Tests
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ master ]
|
6
|
+
pull_request:
|
7
|
+
branches: [ master ]
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
test_sqlite:
|
11
|
+
runs-on: ubuntu-20.04
|
12
|
+
|
13
|
+
strategy:
|
14
|
+
fail-fast: false
|
15
|
+
matrix:
|
16
|
+
include:
|
17
|
+
- ruby: "2.3.8"
|
18
|
+
gemfile: Gemfile.3.2.sqlite3
|
19
|
+
- ruby: "2.3.8"
|
20
|
+
gemfile: Gemfile.4.2.sqlite3
|
21
|
+
- ruby: "2.3.8"
|
22
|
+
gemfile: Gemfile.5.2.sqlite3
|
23
|
+
- ruby: "2.5.5"
|
24
|
+
gemfile: Gemfile.5.2.sqlite3
|
25
|
+
- ruby: "2.5.5"
|
26
|
+
gemfile: Gemfile.6.0.sqlite3
|
27
|
+
- ruby: "2.5.5"
|
28
|
+
gemfile: Gemfile.6.1.sqlite3
|
29
|
+
- ruby: "2.6.3"
|
30
|
+
gemfile: Gemfile.5.2.sqlite3
|
31
|
+
- ruby: "2.6.3"
|
32
|
+
gemfile: Gemfile.6.0.sqlite3
|
33
|
+
- ruby: "2.6.3"
|
34
|
+
gemfile: Gemfile.6.1.sqlite3
|
35
|
+
- ruby: "2.7.2"
|
36
|
+
gemfile: Gemfile.5.2.sqlite3
|
37
|
+
- ruby: "2.7.2"
|
38
|
+
gemfile: Gemfile.6.0.sqlite3
|
39
|
+
- ruby: "2.7.2"
|
40
|
+
gemfile: Gemfile.6.1.sqlite3
|
41
|
+
- ruby: "3.0.1"
|
42
|
+
gemfile: Gemfile.6.0.sqlite3
|
43
|
+
- ruby: "3.0.1"
|
44
|
+
gemfile: Gemfile.6.1.sqlite3
|
45
|
+
|
46
|
+
env:
|
47
|
+
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
|
48
|
+
|
49
|
+
steps:
|
50
|
+
- uses: actions/checkout@v2
|
51
|
+
- name: Install ruby
|
52
|
+
uses: ruby/setup-ruby@v1
|
53
|
+
with:
|
54
|
+
ruby-version: ${{ matrix.ruby }}
|
55
|
+
- name: Bundle
|
56
|
+
run: |
|
57
|
+
gem install bundler:2.0.2
|
58
|
+
bundle install --no-deployment
|
59
|
+
- name: Run tests
|
60
|
+
run: bundle exec rake spec
|
61
|
+
|
62
|
+
|
63
|
+
test_mysql:
|
64
|
+
runs-on: ubuntu-20.04
|
65
|
+
|
66
|
+
services:
|
67
|
+
mysql:
|
68
|
+
image: mysql:5.6
|
69
|
+
env:
|
70
|
+
MYSQL_ROOT_PASSWORD: password
|
71
|
+
ports:
|
72
|
+
- 3306:3306
|
73
|
+
options: >-
|
74
|
+
--health-cmd="mysqladmin ping"
|
75
|
+
--health-interval=10s
|
76
|
+
--health-timeout=5s
|
77
|
+
--health-retries=3
|
78
|
+
|
79
|
+
strategy:
|
80
|
+
fail-fast: false
|
81
|
+
matrix:
|
82
|
+
include:
|
83
|
+
- ruby: "2.3.8"
|
84
|
+
gemfile: Gemfile.3.2.mysql2
|
85
|
+
- ruby: "2.3.8"
|
86
|
+
gemfile: Gemfile.4.2.mysql2
|
87
|
+
- ruby: "2.3.8"
|
88
|
+
gemfile: Gemfile.5.2.mysql2
|
89
|
+
- ruby: "2.6.3"
|
90
|
+
gemfile: Gemfile.5.2.mysql2
|
91
|
+
- ruby: "2.7.2"
|
92
|
+
gemfile: Gemfile.5.2.mysql2
|
93
|
+
|
94
|
+
env:
|
95
|
+
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
|
96
|
+
|
97
|
+
steps:
|
98
|
+
- uses: actions/checkout@v2
|
99
|
+
- name: Install ruby
|
100
|
+
uses: ruby/setup-ruby@v1
|
101
|
+
with:
|
102
|
+
ruby-version: ${{ matrix.ruby }}
|
103
|
+
- name: Install database client
|
104
|
+
run: |
|
105
|
+
sudo apt-get update
|
106
|
+
sudo apt-get install -y mysql-client libmariadbclient-dev
|
107
|
+
- name: Bundle
|
108
|
+
run: |
|
109
|
+
gem install bundler:2.0.2
|
110
|
+
bundle install --no-deployment
|
111
|
+
- name: Setup databases
|
112
|
+
run: |
|
113
|
+
mysql -e 'create database IF NOT EXISTS active_type_test;' -u root --password=password -P 3306 -h 127.0.0.1
|
114
|
+
- name: Run tests
|
115
|
+
run: bundle exec rake spec
|
116
|
+
|
117
|
+
|
118
|
+
test_pg:
|
119
|
+
runs-on: ubuntu-20.04
|
120
|
+
|
121
|
+
services:
|
122
|
+
postgres:
|
123
|
+
image: postgres
|
124
|
+
env:
|
125
|
+
POSTGRES_PASSWORD: postgres
|
126
|
+
options: >-
|
127
|
+
--health-cmd pg_isready
|
128
|
+
--health-interval 10s
|
129
|
+
--health-timeout 5s
|
130
|
+
--health-retries 5
|
131
|
+
ports:
|
132
|
+
- 5432:5432
|
133
|
+
|
134
|
+
strategy:
|
135
|
+
fail-fast: false
|
136
|
+
matrix:
|
137
|
+
include:
|
138
|
+
- ruby: "2.3.8"
|
139
|
+
gemfile: Gemfile.4.2.pg
|
140
|
+
- ruby: "2.3.8"
|
141
|
+
gemfile: Gemfile.5.2.pg
|
142
|
+
- ruby: "2.5.5"
|
143
|
+
gemfile: Gemfile.6.1.pg
|
144
|
+
- ruby: "2.6.3"
|
145
|
+
gemfile: Gemfile.5.2.pg
|
146
|
+
- ruby: "2.6.3"
|
147
|
+
gemfile: Gemfile.6.1.pg
|
148
|
+
- ruby: "2.7.2"
|
149
|
+
gemfile: Gemfile.5.2.pg
|
150
|
+
- ruby: "2.7.2"
|
151
|
+
gemfile: Gemfile.6.1.pg
|
152
|
+
- ruby: "3.0.1"
|
153
|
+
gemfile: Gemfile.6.1.pg
|
154
|
+
|
155
|
+
env:
|
156
|
+
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
|
157
|
+
|
158
|
+
steps:
|
159
|
+
- uses: actions/checkout@v2
|
160
|
+
- name: Install ruby
|
161
|
+
uses: ruby/setup-ruby@v1
|
162
|
+
with:
|
163
|
+
ruby-version: ${{ matrix.ruby }}
|
164
|
+
- name: Install database client
|
165
|
+
run: |
|
166
|
+
sudo apt-get install -y postgresql-client
|
167
|
+
- name: Bundle
|
168
|
+
run: |
|
169
|
+
gem install bundler:2.0.2
|
170
|
+
bundle install --no-deployment
|
171
|
+
- name: Setup databases
|
172
|
+
run: |
|
173
|
+
PGPASSWORD=postgres psql -c 'create database active_type_test;' -U postgres -p 5432 -h localhost
|
174
|
+
- name: Run tests
|
175
|
+
run: bundle exec rake spec
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,31 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
|
5
5
|
## Unreleased changes
|
6
6
|
|
7
|
+
## 1.9.0 (2021-05-20)
|
8
|
+
|
9
|
+
* Fixed: Extended records now use their own I18n namespace when looking up translations for models or attributes.
|
10
|
+
(introduced in [1.4.0](https://github.com/makandra/active_type/commit/b2aa4247ed1d45a4cd7e51e13d945cba7c38c597))
|
11
|
+
|
12
|
+
There was an issue ([#142](https://github.com/makandra/active_type/issues/142)) when extending an already extended records again. Now the I18n lookup will fall back
|
13
|
+
fall back correctly to the extended record's or even the base record's namespace.
|
14
|
+
|
15
|
+
## 1.8.0 (2021-04-27)
|
16
|
+
|
17
|
+
* Added: When casting an unsaved record, the new record will have the same associations as the base record.
|
18
|
+
|
19
|
+
## 1.7.0 (2021-04-27)
|
20
|
+
|
21
|
+
* Added: Support for Ruby 3.0.
|
22
|
+
|
23
|
+
## 1.6.0 (2021-03-04)
|
24
|
+
|
25
|
+
* Fixed: Numerous issues with Rails 6.1. Thanks to @vr4b4c for some of the changes.
|
26
|
+
|
27
|
+
## 1.5.0 (2020-11-06)
|
28
|
+
|
29
|
+
* Added: When serializing/deserializing `ActiveType::Record` or `ActiveType::Object` with YAML, virtual attributes are restored.
|
30
|
+
Credits to @chriscz.
|
31
|
+
|
7
32
|
## 1.4.2 (2020-09-17)
|
8
33
|
|
9
34
|
* Fixed: Assigning values to virtual attributes through internal setter methods (e.g. `_write_attribute`) no longer results in "can't write unknown attribute" errors.
|
data/Gemfile
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
Gemfile.5.2.pg
|
data/Gemfile.3.2.mysql2
CHANGED
data/Gemfile.3.2.mysql2.lock
CHANGED
@@ -1,7 +1,14 @@
|
|
1
|
+
GIT
|
2
|
+
remote: https://github.com/makandra/mysql2
|
3
|
+
revision: c920d41e43c4722d4c065d2ea9d21494c560bd85
|
4
|
+
branch: 0.3.x-lts
|
5
|
+
specs:
|
6
|
+
mysql2 (0.3.21)
|
7
|
+
|
1
8
|
PATH
|
2
9
|
remote: .
|
3
10
|
specs:
|
4
|
-
active_type (1.
|
11
|
+
active_type (1.6.0)
|
5
12
|
activerecord (>= 3.2)
|
6
13
|
|
7
14
|
GEM
|
@@ -21,10 +28,9 @@ GEM
|
|
21
28
|
arel (3.0.3)
|
22
29
|
builder (3.0.4)
|
23
30
|
diff-lcs (1.2.5)
|
24
|
-
gemika (0.
|
31
|
+
gemika (0.4.1)
|
25
32
|
i18n (0.6.11)
|
26
33
|
multi_json (1.13.1)
|
27
|
-
mysql2 (0.3.17)
|
28
34
|
rake (10.4.2)
|
29
35
|
rspec (3.4.0)
|
30
36
|
rspec-core (~> 3.4.0)
|
@@ -49,7 +55,7 @@ DEPENDENCIES
|
|
49
55
|
activerecord (~> 3.2.22.5)
|
50
56
|
gemika
|
51
57
|
i18n (= 0.6.11)
|
52
|
-
mysql2
|
58
|
+
mysql2!
|
53
59
|
rake
|
54
60
|
rspec (~> 3.4)
|
55
61
|
|
data/Gemfile.3.2.sqlite3.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
active_type (1.
|
4
|
+
active_type (1.6.0)
|
5
5
|
activerecord (>= 3.2)
|
6
6
|
|
7
7
|
GEM
|
@@ -21,7 +21,7 @@ GEM
|
|
21
21
|
arel (3.0.3)
|
22
22
|
builder (3.0.4)
|
23
23
|
diff-lcs (1.2.5)
|
24
|
-
gemika (0.
|
24
|
+
gemika (0.4.1)
|
25
25
|
i18n (0.6.11)
|
26
26
|
multi_json (1.13.1)
|
27
27
|
rake (10.4.2)
|
data/Gemfile.4.2.mysql2
CHANGED
data/Gemfile.4.2.mysql2.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
active_type (1.
|
4
|
+
active_type (1.6.0)
|
5
5
|
activerecord (>= 3.2)
|
6
6
|
|
7
7
|
GEM
|
@@ -23,11 +23,11 @@ GEM
|
|
23
23
|
builder (3.2.3)
|
24
24
|
concurrent-ruby (1.1.4)
|
25
25
|
diff-lcs (1.2.5)
|
26
|
-
gemika (0.
|
26
|
+
gemika (0.4.1)
|
27
27
|
i18n (0.9.5)
|
28
28
|
concurrent-ruby (~> 1.0)
|
29
29
|
minitest (5.11.3)
|
30
|
-
mysql2 (0.3
|
30
|
+
mysql2 (0.5.3)
|
31
31
|
rake (10.4.2)
|
32
32
|
rspec (3.4.0)
|
33
33
|
rspec-core (~> 3.4.0)
|
@@ -53,7 +53,7 @@ DEPENDENCIES
|
|
53
53
|
active_type!
|
54
54
|
activerecord (~> 4.2.1)
|
55
55
|
gemika
|
56
|
-
mysql2
|
56
|
+
mysql2
|
57
57
|
rake
|
58
58
|
rspec (~> 3.4)
|
59
59
|
|
data/Gemfile.4.2.pg.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
active_type (1.
|
4
|
+
active_type (1.6.0)
|
5
5
|
activerecord (>= 3.2)
|
6
6
|
|
7
7
|
GEM
|
@@ -23,7 +23,7 @@ GEM
|
|
23
23
|
builder (3.2.3)
|
24
24
|
concurrent-ruby (1.1.4)
|
25
25
|
diff-lcs (1.2.5)
|
26
|
-
gemika (0.
|
26
|
+
gemika (0.4.1)
|
27
27
|
i18n (0.9.5)
|
28
28
|
concurrent-ruby (~> 1.0)
|
29
29
|
minitest (5.11.3)
|
data/Gemfile.4.2.sqlite3.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
active_type (1.
|
4
|
+
active_type (1.6.0)
|
5
5
|
activerecord (>= 3.2)
|
6
6
|
|
7
7
|
GEM
|
@@ -23,7 +23,7 @@ GEM
|
|
23
23
|
builder (3.2.3)
|
24
24
|
concurrent-ruby (1.1.4)
|
25
25
|
diff-lcs (1.2.5)
|
26
|
-
gemika (0.
|
26
|
+
gemika (0.4.1)
|
27
27
|
i18n (0.9.5)
|
28
28
|
concurrent-ruby (~> 1.0)
|
29
29
|
minitest (5.11.3)
|
data/Gemfile.5.2.mysql2.lock
CHANGED
@@ -1,47 +1,47 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
active_type (1.
|
4
|
+
active_type (1.9.0)
|
5
5
|
activerecord (>= 3.2)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
activemodel (5.1.
|
11
|
-
activesupport (= 5.1.
|
12
|
-
activerecord (5.1.
|
13
|
-
activemodel (= 5.1.
|
14
|
-
activesupport (= 5.1.
|
10
|
+
activemodel (5.1.7)
|
11
|
+
activesupport (= 5.1.7)
|
12
|
+
activerecord (5.1.7)
|
13
|
+
activemodel (= 5.1.7)
|
14
|
+
activesupport (= 5.1.7)
|
15
15
|
arel (~> 8.0)
|
16
|
-
activesupport (5.1.
|
16
|
+
activesupport (5.1.7)
|
17
17
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
18
18
|
i18n (>= 0.7, < 2)
|
19
19
|
minitest (~> 5.1)
|
20
20
|
tzinfo (~> 1.1)
|
21
21
|
arel (8.0.0)
|
22
|
-
concurrent-ruby (1.1.
|
23
|
-
diff-lcs (1.
|
24
|
-
gemika (0.
|
25
|
-
i18n (1.5
|
22
|
+
concurrent-ruby (1.1.7)
|
23
|
+
diff-lcs (1.4.4)
|
24
|
+
gemika (0.5.0)
|
25
|
+
i18n (1.8.5)
|
26
26
|
concurrent-ruby (~> 1.0)
|
27
|
-
minitest (5.
|
28
|
-
mysql2 (0.
|
29
|
-
rake (
|
30
|
-
rspec (3.
|
31
|
-
rspec-core (~> 3.
|
32
|
-
rspec-expectations (~> 3.
|
33
|
-
rspec-mocks (~> 3.
|
34
|
-
rspec-core (3.
|
35
|
-
rspec-support (~> 3.
|
36
|
-
rspec-expectations (3.
|
27
|
+
minitest (5.14.2)
|
28
|
+
mysql2 (0.5.3)
|
29
|
+
rake (13.0.1)
|
30
|
+
rspec (3.10.0)
|
31
|
+
rspec-core (~> 3.10.0)
|
32
|
+
rspec-expectations (~> 3.10.0)
|
33
|
+
rspec-mocks (~> 3.10.0)
|
34
|
+
rspec-core (3.10.0)
|
35
|
+
rspec-support (~> 3.10.0)
|
36
|
+
rspec-expectations (3.10.0)
|
37
37
|
diff-lcs (>= 1.2.0, < 2.0)
|
38
|
-
rspec-support (~> 3.
|
39
|
-
rspec-mocks (3.
|
38
|
+
rspec-support (~> 3.10.0)
|
39
|
+
rspec-mocks (3.10.0)
|
40
40
|
diff-lcs (>= 1.2.0, < 2.0)
|
41
|
-
rspec-support (~> 3.
|
42
|
-
rspec-support (3.
|
41
|
+
rspec-support (~> 3.10.0)
|
42
|
+
rspec-support (3.10.0)
|
43
43
|
thread_safe (0.3.6)
|
44
|
-
tzinfo (1.2.
|
44
|
+
tzinfo (1.2.8)
|
45
45
|
thread_safe (~> 0.1)
|
46
46
|
|
47
47
|
PLATFORMS
|
@@ -56,4 +56,4 @@ DEPENDENCIES
|
|
56
56
|
rspec (~> 3.4)
|
57
57
|
|
58
58
|
BUNDLED WITH
|
59
|
-
2.
|
59
|
+
2.2.16
|
data/Gemfile.5.2.pg.lock
CHANGED
@@ -1,47 +1,47 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
active_type (1.
|
4
|
+
active_type (1.9.0)
|
5
5
|
activerecord (>= 3.2)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
activemodel (5.1.
|
11
|
-
activesupport (= 5.1.
|
12
|
-
activerecord (5.1.
|
13
|
-
activemodel (= 5.1.
|
14
|
-
activesupport (= 5.1.
|
10
|
+
activemodel (5.1.7)
|
11
|
+
activesupport (= 5.1.7)
|
12
|
+
activerecord (5.1.7)
|
13
|
+
activemodel (= 5.1.7)
|
14
|
+
activesupport (= 5.1.7)
|
15
15
|
arel (~> 8.0)
|
16
|
-
activesupport (5.1.
|
16
|
+
activesupport (5.1.7)
|
17
17
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
18
18
|
i18n (>= 0.7, < 2)
|
19
19
|
minitest (~> 5.1)
|
20
20
|
tzinfo (~> 1.1)
|
21
21
|
arel (8.0.0)
|
22
|
-
concurrent-ruby (1.1.
|
23
|
-
diff-lcs (1.
|
24
|
-
gemika (0.
|
25
|
-
i18n (1.5
|
22
|
+
concurrent-ruby (1.1.7)
|
23
|
+
diff-lcs (1.4.4)
|
24
|
+
gemika (0.6.0)
|
25
|
+
i18n (1.8.5)
|
26
26
|
concurrent-ruby (~> 1.0)
|
27
|
-
minitest (5.
|
28
|
-
pg (
|
29
|
-
rake (
|
30
|
-
rspec (3.
|
31
|
-
rspec-core (~> 3.
|
32
|
-
rspec-expectations (~> 3.
|
33
|
-
rspec-mocks (~> 3.
|
34
|
-
rspec-core (3.
|
35
|
-
rspec-support (~> 3.
|
36
|
-
rspec-expectations (3.
|
27
|
+
minitest (5.14.2)
|
28
|
+
pg (1.2.3)
|
29
|
+
rake (13.0.1)
|
30
|
+
rspec (3.10.0)
|
31
|
+
rspec-core (~> 3.10.0)
|
32
|
+
rspec-expectations (~> 3.10.0)
|
33
|
+
rspec-mocks (~> 3.10.0)
|
34
|
+
rspec-core (3.10.0)
|
35
|
+
rspec-support (~> 3.10.0)
|
36
|
+
rspec-expectations (3.10.0)
|
37
37
|
diff-lcs (>= 1.2.0, < 2.0)
|
38
|
-
rspec-support (~> 3.
|
39
|
-
rspec-mocks (3.
|
38
|
+
rspec-support (~> 3.10.0)
|
39
|
+
rspec-mocks (3.10.0)
|
40
40
|
diff-lcs (>= 1.2.0, < 2.0)
|
41
|
-
rspec-support (~> 3.
|
42
|
-
rspec-support (3.
|
41
|
+
rspec-support (~> 3.10.0)
|
42
|
+
rspec-support (3.10.0)
|
43
43
|
thread_safe (0.3.6)
|
44
|
-
tzinfo (1.2.
|
44
|
+
tzinfo (1.2.8)
|
45
45
|
thread_safe (~> 0.1)
|
46
46
|
|
47
47
|
PLATFORMS
|
@@ -56,4 +56,4 @@ DEPENDENCIES
|
|
56
56
|
rspec (~> 3.4)
|
57
57
|
|
58
58
|
BUNDLED WITH
|
59
|
-
2.
|
59
|
+
2.2.16
|
data/Gemfile.5.2.sqlite3.lock
CHANGED
@@ -1,47 +1,47 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
active_type (1.
|
4
|
+
active_type (1.9.0)
|
5
5
|
activerecord (>= 3.2)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
activemodel (5.1.
|
11
|
-
activesupport (= 5.1.
|
12
|
-
activerecord (5.1.
|
13
|
-
activemodel (= 5.1.
|
14
|
-
activesupport (= 5.1.
|
10
|
+
activemodel (5.1.7)
|
11
|
+
activesupport (= 5.1.7)
|
12
|
+
activerecord (5.1.7)
|
13
|
+
activemodel (= 5.1.7)
|
14
|
+
activesupport (= 5.1.7)
|
15
15
|
arel (~> 8.0)
|
16
|
-
activesupport (5.1.
|
16
|
+
activesupport (5.1.7)
|
17
17
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
18
18
|
i18n (>= 0.7, < 2)
|
19
19
|
minitest (~> 5.1)
|
20
20
|
tzinfo (~> 1.1)
|
21
21
|
arel (8.0.0)
|
22
|
-
concurrent-ruby (1.1.
|
23
|
-
diff-lcs (1.
|
24
|
-
gemika (0.
|
25
|
-
i18n (1.5
|
22
|
+
concurrent-ruby (1.1.7)
|
23
|
+
diff-lcs (1.4.4)
|
24
|
+
gemika (0.5.0)
|
25
|
+
i18n (1.8.5)
|
26
26
|
concurrent-ruby (~> 1.0)
|
27
|
-
minitest (5.
|
28
|
-
rake (
|
29
|
-
rspec (3.
|
30
|
-
rspec-core (~> 3.
|
31
|
-
rspec-expectations (~> 3.
|
32
|
-
rspec-mocks (~> 3.
|
33
|
-
rspec-core (3.
|
34
|
-
rspec-support (~> 3.
|
35
|
-
rspec-expectations (3.
|
27
|
+
minitest (5.14.2)
|
28
|
+
rake (13.0.1)
|
29
|
+
rspec (3.10.0)
|
30
|
+
rspec-core (~> 3.10.0)
|
31
|
+
rspec-expectations (~> 3.10.0)
|
32
|
+
rspec-mocks (~> 3.10.0)
|
33
|
+
rspec-core (3.10.0)
|
34
|
+
rspec-support (~> 3.10.0)
|
35
|
+
rspec-expectations (3.10.0)
|
36
36
|
diff-lcs (>= 1.2.0, < 2.0)
|
37
|
-
rspec-support (~> 3.
|
38
|
-
rspec-mocks (3.
|
37
|
+
rspec-support (~> 3.10.0)
|
38
|
+
rspec-mocks (3.10.0)
|
39
39
|
diff-lcs (>= 1.2.0, < 2.0)
|
40
|
-
rspec-support (~> 3.
|
41
|
-
rspec-support (3.
|
42
|
-
sqlite3 (1.
|
40
|
+
rspec-support (~> 3.10.0)
|
41
|
+
rspec-support (3.10.0)
|
42
|
+
sqlite3 (1.4.2)
|
43
43
|
thread_safe (0.3.6)
|
44
|
-
tzinfo (1.2.
|
44
|
+
tzinfo (1.2.8)
|
45
45
|
thread_safe (~> 0.1)
|
46
46
|
|
47
47
|
PLATFORMS
|
@@ -56,4 +56,4 @@ DEPENDENCIES
|
|
56
56
|
sqlite3
|
57
57
|
|
58
58
|
BUNDLED WITH
|
59
|
-
2.
|
59
|
+
2.2.16
|
@@ -0,0 +1,59 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
active_type (1.9.0)
|
5
|
+
activerecord (>= 3.2)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
activemodel (6.0.3.4)
|
11
|
+
activesupport (= 6.0.3.4)
|
12
|
+
activerecord (6.0.3.4)
|
13
|
+
activemodel (= 6.0.3.4)
|
14
|
+
activesupport (= 6.0.3.4)
|
15
|
+
activesupport (6.0.3.4)
|
16
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
17
|
+
i18n (>= 0.7, < 2)
|
18
|
+
minitest (~> 5.1)
|
19
|
+
tzinfo (~> 1.1)
|
20
|
+
zeitwerk (~> 2.2, >= 2.2.2)
|
21
|
+
concurrent-ruby (1.1.7)
|
22
|
+
diff-lcs (1.4.4)
|
23
|
+
gemika (0.6.0)
|
24
|
+
i18n (1.8.5)
|
25
|
+
concurrent-ruby (~> 1.0)
|
26
|
+
minitest (5.14.2)
|
27
|
+
rake (13.0.1)
|
28
|
+
rspec (3.10.0)
|
29
|
+
rspec-core (~> 3.10.0)
|
30
|
+
rspec-expectations (~> 3.10.0)
|
31
|
+
rspec-mocks (~> 3.10.0)
|
32
|
+
rspec-core (3.10.0)
|
33
|
+
rspec-support (~> 3.10.0)
|
34
|
+
rspec-expectations (3.10.0)
|
35
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
36
|
+
rspec-support (~> 3.10.0)
|
37
|
+
rspec-mocks (3.10.0)
|
38
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
39
|
+
rspec-support (~> 3.10.0)
|
40
|
+
rspec-support (3.10.0)
|
41
|
+
sqlite3 (1.4.2)
|
42
|
+
thread_safe (0.3.6)
|
43
|
+
tzinfo (1.2.8)
|
44
|
+
thread_safe (~> 0.1)
|
45
|
+
zeitwerk (2.4.1)
|
46
|
+
|
47
|
+
PLATFORMS
|
48
|
+
ruby
|
49
|
+
|
50
|
+
DEPENDENCIES
|
51
|
+
active_type!
|
52
|
+
activerecord (~> 6.0.0)
|
53
|
+
gemika
|
54
|
+
rake
|
55
|
+
rspec (~> 3.4)
|
56
|
+
sqlite3
|
57
|
+
|
58
|
+
BUNDLED WITH
|
59
|
+
2.2.16
|
data/Gemfile.6.1.pg
ADDED
data/Gemfile.6.1.pg.lock
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
active_type (1.9.0)
|
5
|
+
activerecord (>= 3.2)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
activemodel (6.1.3)
|
11
|
+
activesupport (= 6.1.3)
|
12
|
+
activerecord (6.1.3)
|
13
|
+
activemodel (= 6.1.3)
|
14
|
+
activesupport (= 6.1.3)
|
15
|
+
activesupport (6.1.3)
|
16
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
17
|
+
i18n (>= 1.6, < 2)
|
18
|
+
minitest (>= 5.1)
|
19
|
+
tzinfo (~> 2.0)
|
20
|
+
zeitwerk (~> 2.3)
|
21
|
+
concurrent-ruby (1.1.8)
|
22
|
+
diff-lcs (1.4.4)
|
23
|
+
gemika (0.6.0)
|
24
|
+
i18n (1.8.9)
|
25
|
+
concurrent-ruby (~> 1.0)
|
26
|
+
minitest (5.14.4)
|
27
|
+
pg (1.2.3)
|
28
|
+
rake (13.0.3)
|
29
|
+
rspec (3.10.0)
|
30
|
+
rspec-core (~> 3.10.0)
|
31
|
+
rspec-expectations (~> 3.10.0)
|
32
|
+
rspec-mocks (~> 3.10.0)
|
33
|
+
rspec-core (3.10.1)
|
34
|
+
rspec-support (~> 3.10.0)
|
35
|
+
rspec-expectations (3.10.1)
|
36
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
37
|
+
rspec-support (~> 3.10.0)
|
38
|
+
rspec-mocks (3.10.2)
|
39
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
40
|
+
rspec-support (~> 3.10.0)
|
41
|
+
rspec-support (3.10.2)
|
42
|
+
tzinfo (2.0.4)
|
43
|
+
concurrent-ruby (~> 1.0)
|
44
|
+
zeitwerk (2.4.2)
|
45
|
+
|
46
|
+
PLATFORMS
|
47
|
+
x86_64-linux
|
48
|
+
|
49
|
+
DEPENDENCIES
|
50
|
+
active_type!
|
51
|
+
activerecord (~> 6.1.0)
|
52
|
+
gemika
|
53
|
+
pg
|
54
|
+
rake
|
55
|
+
rspec (~> 3.4)
|
56
|
+
|
57
|
+
BUNDLED WITH
|
58
|
+
2.2.16
|
data/Gemfile.6.1.sqlite3
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
active_type (1.9.0)
|
5
|
+
activerecord (>= 3.2)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
activemodel (6.1.3)
|
11
|
+
activesupport (= 6.1.3)
|
12
|
+
activerecord (6.1.3)
|
13
|
+
activemodel (= 6.1.3)
|
14
|
+
activesupport (= 6.1.3)
|
15
|
+
activesupport (6.1.3)
|
16
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
17
|
+
i18n (>= 1.6, < 2)
|
18
|
+
minitest (>= 5.1)
|
19
|
+
tzinfo (~> 2.0)
|
20
|
+
zeitwerk (~> 2.3)
|
21
|
+
concurrent-ruby (1.1.8)
|
22
|
+
diff-lcs (1.4.4)
|
23
|
+
gemika (0.6.0)
|
24
|
+
i18n (1.8.9)
|
25
|
+
concurrent-ruby (~> 1.0)
|
26
|
+
minitest (5.14.4)
|
27
|
+
rake (13.0.3)
|
28
|
+
rspec (3.10.0)
|
29
|
+
rspec-core (~> 3.10.0)
|
30
|
+
rspec-expectations (~> 3.10.0)
|
31
|
+
rspec-mocks (~> 3.10.0)
|
32
|
+
rspec-core (3.10.1)
|
33
|
+
rspec-support (~> 3.10.0)
|
34
|
+
rspec-expectations (3.10.1)
|
35
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
36
|
+
rspec-support (~> 3.10.0)
|
37
|
+
rspec-mocks (3.10.2)
|
38
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
39
|
+
rspec-support (~> 3.10.0)
|
40
|
+
rspec-support (3.10.2)
|
41
|
+
sqlite3 (1.4.2)
|
42
|
+
tzinfo (2.0.4)
|
43
|
+
concurrent-ruby (~> 1.0)
|
44
|
+
zeitwerk (2.4.2)
|
45
|
+
|
46
|
+
PLATFORMS
|
47
|
+
x86_64-linux
|
48
|
+
|
49
|
+
DEPENDENCIES
|
50
|
+
active_type!
|
51
|
+
activerecord (~> 6.1.0)
|
52
|
+
gemika
|
53
|
+
rake
|
54
|
+
rspec (~> 3.4)
|
55
|
+
sqlite3
|
56
|
+
|
57
|
+
BUNDLED WITH
|
58
|
+
2.2.16
|
data/Gemfile.lock
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
Gemfile.5.2.pg.lock
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
ActiveType [![
|
1
|
+
ActiveType [![Tests](https://github.com/makandra/active_type/workflows/Tests/badge.svg)](https://github.com/makandra/active_type/actions)
|
2
2
|
==========
|
3
3
|
|
4
4
|
Make any Ruby object quack like ActiveRecord
|
@@ -51,7 +51,7 @@ end
|
|
51
51
|
```
|
52
52
|
|
53
53
|
|
54
|
-
### A note on Rails 5
|
54
|
+
### A note on Rails 5+
|
55
55
|
|
56
56
|
Rails 5 comes with its own implementation of `.attribute`. This implementation is functionally very
|
57
57
|
similar, but not identical to ActiveType's.
|
@@ -114,6 +114,9 @@ This means your object has all usual `ActiveRecord::Base` methods. Some of those
|
|
114
114
|
- "saving" (returning `true` or `false`, without actually persisting)
|
115
115
|
- belongs_to (after saying `attribute :child_id, :integer`)
|
116
116
|
|
117
|
+
#### Note on transactions
|
118
|
+
|
119
|
+
Since `ActiveType::Object` is not backed by a database, it does not open a real transaction when saving, so you should not rely on database changes that might have happend in a `#save` callback to be rolled back when `#save` fails. If you need this, make sure to wrap those changes in an explicit transaction yourself.
|
117
120
|
|
118
121
|
### ActiveType::Record
|
119
122
|
|
@@ -126,7 +129,7 @@ Virtual attributes will not be persisted.
|
|
126
129
|
|
127
130
|
`ActiveType::Record[BaseClass]` is used to extend a given `BaseClass` (that itself has to be an `ActiveRecord` model) with additional functionality, that is not meant to be shared to the rest of the application.
|
128
131
|
|
129
|
-
|
132
|
+
Your class will inherit from `BaseClass`. You can add additional methods, validations, callbacks, as well as use (virtual) attributes like an `ActiveType::Object`:
|
130
133
|
|
131
134
|
```ruby
|
132
135
|
class SignUp < ActiveType::Record[User]
|
@@ -134,6 +137,17 @@ class SignUp < ActiveType::Record[User]
|
|
134
137
|
end
|
135
138
|
```
|
136
139
|
|
140
|
+
If you need to access the extended `BaseClass` from your presenter model, you may call `extended_record_base_class` on its class:
|
141
|
+
|
142
|
+
```ruby
|
143
|
+
SignUp.extended_record_base_class # => "User (...)"
|
144
|
+
|
145
|
+
# or
|
146
|
+
sign_up = SignUp.new
|
147
|
+
sign_up.class # => "SignUp (...)"
|
148
|
+
sign_up.class.extended_record_base_class # => "User (...)"
|
149
|
+
```
|
150
|
+
|
137
151
|
### Inheriting from ActiveType:: objects
|
138
152
|
|
139
153
|
If you want to inherit from an ActiveType class, simply do
|
@@ -391,14 +405,14 @@ Now, if you load `credentials`, you will automatically receive records of type `
|
|
391
405
|
Supported Rails versions
|
392
406
|
------------------------
|
393
407
|
|
394
|
-
ActiveType is tested against ActiveRecord 3.2, 4.2, 5.1,
|
408
|
+
ActiveType is tested against ActiveRecord 3.2, 4.2, 5.1, 5.2, 6.0 and 6.1.
|
395
409
|
|
396
410
|
Later versions might work, earlier will not.
|
397
411
|
|
398
412
|
Supported Ruby versions
|
399
413
|
------------------------
|
400
414
|
|
401
|
-
ActiveType is tested against 2.3, 2.4,
|
415
|
+
ActiveType is tested against 2.3, 2.4, 2.5 and 3.0.
|
402
416
|
|
403
417
|
|
404
418
|
Installation
|
@@ -426,7 +440,7 @@ If you would like to contribute:
|
|
426
440
|
- Push your changes **with passing specs**.
|
427
441
|
- Send us a pull request.
|
428
442
|
|
429
|
-
I'm very eager to keep this gem
|
443
|
+
I'm very eager to keep this gem lightweight and on topic. If you're unsure whether a change would make it into the gem, [talk to me beforehand](mailto:henning.koch@makandra.de).
|
430
444
|
|
431
445
|
|
432
446
|
Credits
|
data/Rakefile
CHANGED
@@ -27,7 +27,7 @@ namespace :matrix do
|
|
27
27
|
|
28
28
|
desc "Run specs for all Ruby #{RUBY_VERSION} gemfiles"
|
29
29
|
task :spec, :files do |t, options|
|
30
|
-
Gemika::Matrix.
|
30
|
+
Gemika::Matrix.from_ci_config.each do |row|
|
31
31
|
options = options.to_hash.merge(
|
32
32
|
:gemfile => row.gemfile,
|
33
33
|
:fatal => false,
|
@@ -15,9 +15,9 @@ module ActiveType
|
|
15
15
|
original_options = existing_association.options
|
16
16
|
if ActiveRecord::VERSION::MAJOR > 3
|
17
17
|
new_scope ||= existing_association.scope
|
18
|
-
public_send(existing_association.macro, association_name, new_scope, original_options.merge(new_options))
|
18
|
+
public_send(existing_association.macro, association_name, new_scope, **original_options.merge(new_options))
|
19
19
|
else
|
20
|
-
public_send(existing_association.macro, association_name, original_options.merge(new_options))
|
20
|
+
public_send(existing_association.macro, association_name, **original_options.merge(new_options))
|
21
21
|
end
|
22
22
|
else
|
23
23
|
raise ArgumentError, "unrecognized association `#{association_name}`"
|
@@ -42,13 +42,7 @@ module ActiveType
|
|
42
42
|
|
43
43
|
def validate(parent)
|
44
44
|
changed_children(parent).each_with_index do |child, index|
|
45
|
-
unless child.valid?
|
46
|
-
child.errors.each do |attribute, message|
|
47
|
-
attribute = @index_errors ? "#{@target_name}[#{index}].#{attribute}" : "#{@target_name}.#{attribute}"
|
48
|
-
parent.errors[attribute] << message
|
49
|
-
parent.errors[attribute].uniq!
|
50
|
-
end
|
51
|
-
end
|
45
|
+
add_errors_to_parent(parent, child, index) unless child.valid?
|
52
46
|
end
|
53
47
|
end
|
54
48
|
|
@@ -131,6 +125,24 @@ module ActiveType
|
|
131
125
|
[:build_scope, :find_scope, :scope, :allow_destroy, :reject_if]
|
132
126
|
end
|
133
127
|
|
128
|
+
def add_errors_to_parent(parent, child, index)
|
129
|
+
if ActiveRecord::VERSION::MAJOR >= 6 && ActiveRecord::VERSION::MINOR >= 1
|
130
|
+
child.errors.each do |error|
|
131
|
+
attribute = translate_error_attribute(error.attribute, index)
|
132
|
+
parent.errors.add(attribute, error.message)
|
133
|
+
end
|
134
|
+
else
|
135
|
+
child.errors.each do |attribute, message|
|
136
|
+
attribute = translate_error_attribute(attribute, index)
|
137
|
+
parent.errors.add(attribute, message)
|
138
|
+
parent.errors[attribute].uniq!
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
def translate_error_attribute(attribute, index)
|
144
|
+
@index_errors ? "#{@target_name}[#{index}].#{attribute}" : "#{@target_name}.#{attribute}"
|
145
|
+
end
|
134
146
|
end
|
135
147
|
|
136
148
|
end
|
@@ -19,7 +19,7 @@ module ActiveType
|
|
19
19
|
options = options.merge(foreign_key: extended_record_base_class.name.foreign_key)
|
20
20
|
end
|
21
21
|
if ActiveRecord::VERSION::MAJOR > 3
|
22
|
-
[
|
22
|
+
[options, scope]
|
23
23
|
else
|
24
24
|
[options]
|
25
25
|
end
|
@@ -34,13 +34,13 @@ module ActiveType
|
|
34
34
|
namespace = module_ancestors.detect do |n|
|
35
35
|
n.respond_to?(:use_relative_model_naming?) && n.use_relative_model_naming?
|
36
36
|
end
|
37
|
-
# We create a Name object, with the
|
37
|
+
# We create a Name object, with the sti class name, but self as the @klass reference
|
38
38
|
# This way lookup_ancestors is invoked on the right class instead of the extended_record_base_class
|
39
|
-
dup_model_name = ActiveModel::Name.new(self, namespace,
|
40
|
-
key = name.underscore
|
41
|
-
# We
|
39
|
+
dup_model_name = ActiveModel::Name.new(self, namespace, sti_name)
|
40
|
+
key = name.underscore.to_sym
|
41
|
+
# We set the `i18n_key` to lookup on the derived class key
|
42
42
|
# We keep the others the same to preserve parameter and route names
|
43
|
-
dup_model_name.
|
43
|
+
dup_model_name.instance_variable_set(:@i18n_key, key)
|
44
44
|
dup_model_name
|
45
45
|
else # name is nil for the anonymous intermediate class
|
46
46
|
extended_record_base_class.model_name
|
@@ -64,12 +64,22 @@ module ActiveType
|
|
64
64
|
extended_record_base_class.descends_from_active_record?
|
65
65
|
end
|
66
66
|
|
67
|
-
def has_many(name, *args, &extension)
|
68
|
-
|
67
|
+
def has_many(name, scope=nil, *args, &extension)
|
68
|
+
new_args, new_scope = Inheritance.add_foreign_key_option(extended_record_base_class, scope, *args)
|
69
|
+
if ActiveRecord::VERSION::MAJOR <= 3 || new_scope.nil?
|
70
|
+
super(name, **new_args, &extension)
|
71
|
+
else
|
72
|
+
super(name, new_scope, **new_args, &extension)
|
73
|
+
end
|
69
74
|
end
|
70
75
|
|
71
|
-
def has_one(name, *args, &extension)
|
72
|
-
|
76
|
+
def has_one(name, scope=nil, *args, &extension)
|
77
|
+
new_args, new_scope = Inheritance.add_foreign_key_option(extended_record_base_class, scope, *args)
|
78
|
+
if ActiveRecord::VERSION::MAJOR <= 3 || new_scope.nil?
|
79
|
+
super(name, **new_args, &extension)
|
80
|
+
else
|
81
|
+
super(name, new_scope, **new_args, &extension)
|
82
|
+
end
|
73
83
|
end
|
74
84
|
|
75
85
|
private
|
data/lib/active_type/util.rb
CHANGED
@@ -34,6 +34,9 @@ module ActiveType
|
|
34
34
|
casted.instance_variable_set(:@new_record, record.new_record?)
|
35
35
|
# Rails 3.2, 4.2
|
36
36
|
casted.instance_variable_set(:@destroyed, record.destroyed?)
|
37
|
+
|
38
|
+
casted.instance_variable_set(:@association_cache, record.instance_variable_get(:@association_cache))
|
39
|
+
|
37
40
|
# Rails 3.2, 4.2
|
38
41
|
errors = record.errors
|
39
42
|
if errors.kind_of? ActiveModel::Errors
|
data/lib/active_type/version.rb
CHANGED
@@ -8,6 +8,23 @@ module ActiveType
|
|
8
8
|
|
9
9
|
module VirtualAttributes
|
10
10
|
|
11
|
+
module Serialization
|
12
|
+
extend ActiveSupport::Concern
|
13
|
+
|
14
|
+
def init_with(coder)
|
15
|
+
if coder['virtual_attributes'].present?
|
16
|
+
@virtual_attributes = coder['virtual_attributes']
|
17
|
+
end
|
18
|
+
super(coder)
|
19
|
+
end
|
20
|
+
|
21
|
+
def encode_with(coder)
|
22
|
+
coder['virtual_attributes'] = @virtual_attributes
|
23
|
+
coder['active_type_yaml_version'] = 1
|
24
|
+
super(coder)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
11
28
|
class VirtualColumn
|
12
29
|
|
13
30
|
def initialize(name, type_caster, options)
|
@@ -110,10 +127,10 @@ module ActiveType
|
|
110
127
|
result
|
111
128
|
end
|
112
129
|
|
113
|
-
|
114
130
|
extend ActiveSupport::Concern
|
115
131
|
|
116
132
|
included do
|
133
|
+
include ActiveType::VirtualAttributes::Serialization
|
117
134
|
class_attribute :virtual_columns_hash
|
118
135
|
self.virtual_columns_hash = {}
|
119
136
|
|
@@ -168,7 +185,10 @@ module ActiveType
|
|
168
185
|
def _read_attribute(name)
|
169
186
|
read_existing_virtual_attribute(name) { super }
|
170
187
|
end
|
171
|
-
|
188
|
+
end
|
189
|
+
|
190
|
+
if ActiveRecord::VERSION::STRING < '4.2.0' || ActiveRecord::VERSION::STRING >= '6.1.0'
|
191
|
+
# in 6.1, read_attribute does not call _read_attribute
|
172
192
|
def read_attribute(name)
|
173
193
|
read_existing_virtual_attribute(name) { super }
|
174
194
|
end
|
@@ -182,7 +202,10 @@ module ActiveType
|
|
182
202
|
def _write_attribute(name, value)
|
183
203
|
write_existing_virtual_attribute(name, value) { super }
|
184
204
|
end
|
185
|
-
|
205
|
+
end
|
206
|
+
|
207
|
+
if ActiveRecord::VERSION::STRING < '5.2.0' || ActiveRecord::VERSION::STRING >= '6.1.0'
|
208
|
+
# in 6.1, write_attribute does not call _write_attribute
|
186
209
|
def write_attribute(name, value)
|
187
210
|
write_existing_virtual_attribute(name, value) { super }
|
188
211
|
end
|
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: 1.
|
4
|
+
version: 1.9.0
|
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:
|
12
|
+
date: 2021-05-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -59,10 +59,10 @@ executables: []
|
|
59
59
|
extensions: []
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
|
+
- ".github/workflows/test.yml"
|
62
63
|
- ".gitignore"
|
63
64
|
- ".rspec"
|
64
65
|
- ".ruby-version"
|
65
|
-
- ".travis.yml"
|
66
66
|
- CHANGELOG.md
|
67
67
|
- Gemfile
|
68
68
|
- Gemfile.3.2.mysql2
|
@@ -81,8 +81,12 @@ files:
|
|
81
81
|
- Gemfile.5.2.pg.lock
|
82
82
|
- Gemfile.5.2.sqlite3
|
83
83
|
- Gemfile.5.2.sqlite3.lock
|
84
|
-
- Gemfile.6.0.
|
85
|
-
- Gemfile.6.0.
|
84
|
+
- Gemfile.6.0.sqlite3
|
85
|
+
- Gemfile.6.0.sqlite3.lock
|
86
|
+
- Gemfile.6.1.pg
|
87
|
+
- Gemfile.6.1.pg.lock
|
88
|
+
- Gemfile.6.1.sqlite3
|
89
|
+
- Gemfile.6.1.sqlite3.lock
|
86
90
|
- Gemfile.lock
|
87
91
|
- LICENSE
|
88
92
|
- README.md
|
@@ -123,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
127
|
- !ruby/object:Gem::Version
|
124
128
|
version: '0'
|
125
129
|
requirements: []
|
126
|
-
rubygems_version: 3.
|
130
|
+
rubygems_version: 3.2.17
|
127
131
|
signing_key:
|
128
132
|
specification_version: 4
|
129
133
|
summary: Make any Ruby object quack like ActiveRecord
|
data/.travis.yml
DELETED
@@ -1,72 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
dist: trusty
|
3
|
-
services:
|
4
|
-
- postgresql
|
5
|
-
rvm:
|
6
|
-
- "2.3.8"
|
7
|
-
- "2.4.6"
|
8
|
-
- "2.5.5"
|
9
|
-
- "2.6.3"
|
10
|
-
gemfile:
|
11
|
-
- Gemfile.3.2.mysql2
|
12
|
-
- Gemfile.3.2.sqlite3
|
13
|
-
- Gemfile.4.2.mysql2
|
14
|
-
- Gemfile.4.2.pg
|
15
|
-
- Gemfile.4.2.sqlite3
|
16
|
-
- Gemfile.5.2.mysql2
|
17
|
-
- Gemfile.5.2.sqlite3
|
18
|
-
- Gemfile.5.2.pg
|
19
|
-
- Gemfile.6.0.pg
|
20
|
-
before_script:
|
21
|
-
- psql -c 'create database active_type_test;' -U postgres
|
22
|
-
- mysql -e 'create database IF NOT EXISTS active_type_test;'
|
23
|
-
script: bundle exec rake spec
|
24
|
-
sudo: false
|
25
|
-
cache: bundler
|
26
|
-
matrix:
|
27
|
-
exclude:
|
28
|
-
- rvm: "2.3.8"
|
29
|
-
gemfile: Gemfile.6.0.pg
|
30
|
-
- rvm: "2.4.6"
|
31
|
-
gemfile: Gemfile.3.2.mysql2
|
32
|
-
- rvm: "2.4.6"
|
33
|
-
gemfile: Gemfile.3.2.sqlite3
|
34
|
-
- rvm: "2.4.6"
|
35
|
-
gemfile: Gemfile.4.2.mysql2
|
36
|
-
- rvm: "2.4.6"
|
37
|
-
gemfile: Gemfile.4.2.pg
|
38
|
-
- rvm: "2.4.6"
|
39
|
-
gemfile: Gemfile.5.2.mysql2
|
40
|
-
- rvm: "2.4.6"
|
41
|
-
gemfile: Gemfile.5.2.pg
|
42
|
-
- rvm: "2.4.6"
|
43
|
-
gemfile: Gemfile.6.0.pg
|
44
|
-
- rvm: "2.5.5"
|
45
|
-
gemfile: Gemfile.3.2.mysql2
|
46
|
-
- rvm: "2.5.5"
|
47
|
-
gemfile: Gemfile.3.2.sqlite3
|
48
|
-
- rvm: "2.5.5"
|
49
|
-
gemfile: Gemfile.4.2.mysql2
|
50
|
-
- rvm: "2.5.5"
|
51
|
-
gemfile: Gemfile.4.2.pg
|
52
|
-
- rvm: "2.5.5"
|
53
|
-
gemfile: Gemfile.4.2.sqlite3
|
54
|
-
- rvm: "2.5.5"
|
55
|
-
gemfile: Gemfile.5.2.mysql2
|
56
|
-
- rvm: "2.5.5"
|
57
|
-
gemfile: Gemfile.5.2.pg
|
58
|
-
- rvm: "2.6.3"
|
59
|
-
gemfile: Gemfile.3.2.mysql2
|
60
|
-
- rvm: "2.6.3"
|
61
|
-
gemfile: Gemfile.3.2.sqlite3
|
62
|
-
- rvm: "2.6.3"
|
63
|
-
gemfile: Gemfile.4.2.mysql2
|
64
|
-
- rvm: "2.6.3"
|
65
|
-
gemfile: Gemfile.4.2.pg
|
66
|
-
- rvm: "2.6.3"
|
67
|
-
gemfile: Gemfile.4.2.sqlite3
|
68
|
-
install:
|
69
|
-
- gem install bundler:2.0.2
|
70
|
-
- bundle install --no-deployment --jobs=3 --retry=3 --path=${BUNDLE_PATH:-vendor/bundle}
|
71
|
-
addons:
|
72
|
-
postgresql: 9.3
|
data/Gemfile.6.0.pg.lock
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
active_type (1.4.2)
|
5
|
-
activerecord (>= 3.2)
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: https://rubygems.org/
|
9
|
-
specs:
|
10
|
-
activemodel (6.0.0)
|
11
|
-
activesupport (= 6.0.0)
|
12
|
-
activerecord (6.0.0)
|
13
|
-
activemodel (= 6.0.0)
|
14
|
-
activesupport (= 6.0.0)
|
15
|
-
activesupport (6.0.0)
|
16
|
-
concurrent-ruby (~> 1.0, >= 1.0.2)
|
17
|
-
i18n (>= 0.7, < 2)
|
18
|
-
minitest (~> 5.1)
|
19
|
-
tzinfo (~> 1.1)
|
20
|
-
zeitwerk (~> 2.1, >= 2.1.8)
|
21
|
-
concurrent-ruby (1.1.5)
|
22
|
-
diff-lcs (1.3)
|
23
|
-
gemika (0.3.4)
|
24
|
-
i18n (1.6.0)
|
25
|
-
concurrent-ruby (~> 1.0)
|
26
|
-
minitest (5.11.3)
|
27
|
-
pg (1.1.4)
|
28
|
-
rake (12.3.2)
|
29
|
-
rspec (3.8.0)
|
30
|
-
rspec-core (~> 3.8.0)
|
31
|
-
rspec-expectations (~> 3.8.0)
|
32
|
-
rspec-mocks (~> 3.8.0)
|
33
|
-
rspec-core (3.8.0)
|
34
|
-
rspec-support (~> 3.8.0)
|
35
|
-
rspec-expectations (3.8.2)
|
36
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
37
|
-
rspec-support (~> 3.8.0)
|
38
|
-
rspec-mocks (3.8.0)
|
39
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
40
|
-
rspec-support (~> 3.8.0)
|
41
|
-
rspec-support (3.8.0)
|
42
|
-
thread_safe (0.3.6)
|
43
|
-
tzinfo (1.2.5)
|
44
|
-
thread_safe (~> 0.1)
|
45
|
-
zeitwerk (2.1.9)
|
46
|
-
|
47
|
-
PLATFORMS
|
48
|
-
ruby
|
49
|
-
|
50
|
-
DEPENDENCIES
|
51
|
-
active_type!
|
52
|
-
activerecord (~> 6.0.0)
|
53
|
-
gemika
|
54
|
-
pg
|
55
|
-
rake
|
56
|
-
rspec (~> 3.4)
|
57
|
-
|
58
|
-
BUNDLED WITH
|
59
|
-
2.1.4
|