active_type 1.3.2 → 1.6.0
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 +190 -0
- data/CHANGELOG.md +40 -0
- data/Gemfile.3.2.mysql2 +1 -1
- data/Gemfile.3.2.mysql2.lock +11 -5
- data/Gemfile.3.2.sqlite3.lock +3 -3
- data/Gemfile.4.2.mysql2 +1 -1
- data/Gemfile.4.2.mysql2.lock +5 -5
- data/Gemfile.4.2.pg.lock +3 -3
- data/Gemfile.4.2.sqlite3.lock +3 -3
- 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/README.md +5 -2
- data/Rakefile +1 -1
- data/lib/active_type/nested_attributes/association.rb +19 -7
- data/lib/active_type/record_extension/inheritance.rb +26 -1
- data/lib/active_type/version.rb +1 -1
- data/lib/active_type/virtual_attributes.rb +53 -11
- metadata +9 -5
- 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: fd106690815f11c7582797456d2915ae313899725bfab18aa1ada385c66367cc
|
|
4
|
+
data.tar.gz: 1aec1dec85d519dfa8d75ae3985e1e182963725369c783eb8b2254f6406bba97
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 611573072b7632eec3d78e7a80263ff4844100b2c401879fbbfe326d8d68cf2f3780fdaa7c260f8917aaadbe343f263472c12a42a797d6dbead714540df2a5bb
|
|
7
|
+
data.tar.gz: 6a0e49c446ada6f2a63cad98ab59ab552015e3fe3c573fe4075ba28f0ddb02b084cb5b604f005da6f99bad2221e8dfdc9c3d6f90963bd6142a62525b0c5af39c
|
|
@@ -0,0 +1,190 @@
|
|
|
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
|
+
ruby:
|
|
17
|
+
- "2.3.8"
|
|
18
|
+
- "2.5.5"
|
|
19
|
+
- "2.6.3"
|
|
20
|
+
- "2.7.2"
|
|
21
|
+
gemfile:
|
|
22
|
+
- Gemfile.3.2.sqlite3
|
|
23
|
+
- Gemfile.4.2.sqlite3
|
|
24
|
+
- Gemfile.5.2.sqlite3
|
|
25
|
+
- Gemfile.6.0.sqlite3
|
|
26
|
+
- Gemfile.6.1.sqlite3
|
|
27
|
+
exclude:
|
|
28
|
+
- ruby: "2.3.8"
|
|
29
|
+
gemfile: Gemfile.6.0.sqlite3
|
|
30
|
+
- ruby: "2.3.8"
|
|
31
|
+
gemfile: Gemfile.6.1.sqlite3
|
|
32
|
+
- ruby: "2.5.5"
|
|
33
|
+
gemfile: Gemfile.3.2.sqlite3
|
|
34
|
+
- ruby: "2.5.5"
|
|
35
|
+
gemfile: Gemfile.4.2.sqlite3
|
|
36
|
+
- ruby: "2.6.3"
|
|
37
|
+
gemfile: Gemfile.3.2.sqlite3
|
|
38
|
+
- ruby: "2.6.3"
|
|
39
|
+
gemfile: Gemfile.4.2.sqlite3
|
|
40
|
+
- ruby: "2.7.2"
|
|
41
|
+
gemfile: Gemfile.3.2.sqlite3
|
|
42
|
+
- ruby: "2.7.2"
|
|
43
|
+
gemfile: Gemfile.4.2.sqlite3
|
|
44
|
+
|
|
45
|
+
env:
|
|
46
|
+
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
|
|
47
|
+
|
|
48
|
+
steps:
|
|
49
|
+
- uses: actions/checkout@v2
|
|
50
|
+
- name: Install ruby
|
|
51
|
+
uses: ruby/setup-ruby@v1
|
|
52
|
+
with:
|
|
53
|
+
ruby-version: ${{ matrix.ruby }}
|
|
54
|
+
- name: Bundle
|
|
55
|
+
run: |
|
|
56
|
+
gem install bundler:2.0.2
|
|
57
|
+
bundle install --no-deployment
|
|
58
|
+
- name: Run tests
|
|
59
|
+
run: bundle exec rake spec
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
test_mysql:
|
|
63
|
+
runs-on: ubuntu-20.04
|
|
64
|
+
|
|
65
|
+
services:
|
|
66
|
+
mysql:
|
|
67
|
+
image: mysql:5.6
|
|
68
|
+
env:
|
|
69
|
+
MYSQL_ROOT_PASSWORD: password
|
|
70
|
+
ports:
|
|
71
|
+
- 3306:3306
|
|
72
|
+
options: >-
|
|
73
|
+
--health-cmd="mysqladmin ping"
|
|
74
|
+
--health-interval=10s
|
|
75
|
+
--health-timeout=5s
|
|
76
|
+
--health-retries=3
|
|
77
|
+
|
|
78
|
+
strategy:
|
|
79
|
+
fail-fast: false
|
|
80
|
+
matrix:
|
|
81
|
+
ruby:
|
|
82
|
+
- "2.3.8"
|
|
83
|
+
- "2.5.5"
|
|
84
|
+
- "2.6.3"
|
|
85
|
+
- "2.7.2"
|
|
86
|
+
gemfile:
|
|
87
|
+
- Gemfile.3.2.mysql2
|
|
88
|
+
- Gemfile.4.2.mysql2
|
|
89
|
+
- Gemfile.5.2.mysql2
|
|
90
|
+
exclude:
|
|
91
|
+
- ruby: "2.5.5"
|
|
92
|
+
gemfile: Gemfile.3.2.mysql2
|
|
93
|
+
- ruby: "2.5.5"
|
|
94
|
+
gemfile: Gemfile.4.2.mysql2
|
|
95
|
+
- ruby: "2.5.5"
|
|
96
|
+
gemfile: Gemfile.5.2.mysql2
|
|
97
|
+
- ruby: "2.6.3"
|
|
98
|
+
gemfile: Gemfile.3.2.mysql2
|
|
99
|
+
- ruby: "2.6.3"
|
|
100
|
+
gemfile: Gemfile.4.2.mysql2
|
|
101
|
+
- ruby: "2.7.2"
|
|
102
|
+
gemfile: Gemfile.3.2.mysql2
|
|
103
|
+
- ruby: "2.7.2"
|
|
104
|
+
gemfile: Gemfile.4.2.mysql2
|
|
105
|
+
|
|
106
|
+
env:
|
|
107
|
+
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
|
|
108
|
+
|
|
109
|
+
steps:
|
|
110
|
+
- uses: actions/checkout@v2
|
|
111
|
+
- name: Install ruby
|
|
112
|
+
uses: ruby/setup-ruby@v1
|
|
113
|
+
with:
|
|
114
|
+
ruby-version: ${{ matrix.ruby }}
|
|
115
|
+
- name: Install database client
|
|
116
|
+
run: |
|
|
117
|
+
sudo apt-get update
|
|
118
|
+
sudo apt-get install -y mysql-client libmariadbclient-dev
|
|
119
|
+
- name: Bundle
|
|
120
|
+
run: |
|
|
121
|
+
gem install bundler:2.0.2
|
|
122
|
+
bundle install --no-deployment
|
|
123
|
+
- name: Setup databases
|
|
124
|
+
run: |
|
|
125
|
+
mysql -e 'create database IF NOT EXISTS active_type_test;' -u root --password=password -P 3306 -h 127.0.0.1
|
|
126
|
+
- name: Run tests
|
|
127
|
+
run: bundle exec rake spec
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
test_pg:
|
|
131
|
+
runs-on: ubuntu-20.04
|
|
132
|
+
|
|
133
|
+
services:
|
|
134
|
+
postgres:
|
|
135
|
+
image: postgres
|
|
136
|
+
env:
|
|
137
|
+
POSTGRES_PASSWORD: postgres
|
|
138
|
+
options: >-
|
|
139
|
+
--health-cmd pg_isready
|
|
140
|
+
--health-interval 10s
|
|
141
|
+
--health-timeout 5s
|
|
142
|
+
--health-retries 5
|
|
143
|
+
ports:
|
|
144
|
+
- 5432:5432
|
|
145
|
+
|
|
146
|
+
strategy:
|
|
147
|
+
fail-fast: false
|
|
148
|
+
matrix:
|
|
149
|
+
ruby:
|
|
150
|
+
- "2.3.8"
|
|
151
|
+
- "2.5.5"
|
|
152
|
+
- "2.6.3"
|
|
153
|
+
- "2.7.2"
|
|
154
|
+
gemfile:
|
|
155
|
+
- Gemfile.4.2.pg
|
|
156
|
+
- Gemfile.5.2.pg
|
|
157
|
+
- Gemfile.6.1.pg
|
|
158
|
+
exclude:
|
|
159
|
+
- ruby: "2.3.8"
|
|
160
|
+
gemfile: Gemfile.6.1.pg
|
|
161
|
+
- ruby: "2.5.5"
|
|
162
|
+
gemfile: Gemfile.4.2.pg
|
|
163
|
+
- ruby: "2.5.5"
|
|
164
|
+
gemfile: Gemfile.5.2.pg
|
|
165
|
+
- ruby: "2.6.3"
|
|
166
|
+
gemfile: Gemfile.4.2.pg
|
|
167
|
+
- ruby: "2.7.2"
|
|
168
|
+
gemfile: Gemfile.4.2.pg
|
|
169
|
+
|
|
170
|
+
env:
|
|
171
|
+
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
|
|
172
|
+
|
|
173
|
+
steps:
|
|
174
|
+
- uses: actions/checkout@v2
|
|
175
|
+
- name: Install ruby
|
|
176
|
+
uses: ruby/setup-ruby@v1
|
|
177
|
+
with:
|
|
178
|
+
ruby-version: ${{ matrix.ruby }}
|
|
179
|
+
- name: Install database client
|
|
180
|
+
run: |
|
|
181
|
+
sudo apt-get install -y postgresql-client
|
|
182
|
+
- name: Bundle
|
|
183
|
+
run: |
|
|
184
|
+
gem install bundler:2.0.2
|
|
185
|
+
bundle install --no-deployment
|
|
186
|
+
- name: Setup databases
|
|
187
|
+
run: |
|
|
188
|
+
PGPASSWORD=postgres psql -c 'create database active_type_test;' -U postgres -p 5432 -h localhost
|
|
189
|
+
- name: Run tests
|
|
190
|
+
run: bundle exec rake spec
|
data/CHANGELOG.md
CHANGED
|
@@ -4,10 +4,50 @@ All notable changes to this project will be documented in this file.
|
|
|
4
4
|
|
|
5
5
|
## Unreleased changes
|
|
6
6
|
|
|
7
|
+
## 1.6.0 (2021-03-04)
|
|
8
|
+
|
|
9
|
+
* Fixed: Numerous issues with Rails 6.1. Thanks to @vr4b4c for some of the changes.
|
|
10
|
+
|
|
11
|
+
## 1.5.0 (2020-11-06)
|
|
12
|
+
|
|
13
|
+
* Added: When serializing/deserializing `ActiveType::Record` or `ActiveType::Object` with YAML, virtual attributes are restored.
|
|
14
|
+
Credits to @chriscz.
|
|
15
|
+
|
|
16
|
+
## 1.4.2 (2020-09-17)
|
|
17
|
+
|
|
18
|
+
* Fixed: Assigning values to virtual attributes through internal setter methods (e.g. `_write_attribute`) no longer results in "can't write unknown attribute" errors.
|
|
19
|
+
|
|
20
|
+
## 1.4.1 (2020-08-05)
|
|
21
|
+
|
|
22
|
+
* Fixed: Avoid `Module#parents` deprecation warning on Rails 6. Thanks to @cilim.
|
|
23
|
+
|
|
24
|
+
## 1.4.0 (2020-07-27)
|
|
25
|
+
|
|
26
|
+
* Extended records now use their own I18n namespace when looking up translations for models or attributes.
|
|
27
|
+
If the extended record's namespace does not contain a translation, the lookup will fall back to the
|
|
28
|
+
base record's namespace.
|
|
29
|
+
|
|
30
|
+
For instance, given the following class hierarchy:
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
class User < ActiveRecord::Base
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
class User::Form < ActiveType::Record[User]
|
|
37
|
+
end
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
The call `ExtendedParent.human_attribute_name(:foo)` would first look up the key in
|
|
41
|
+
`activerecord.attributes.user/form` first, then falls back to `activerecord.attributes.user`.
|
|
42
|
+
|
|
43
|
+
Thank you @fsateler!
|
|
44
|
+
|
|
45
|
+
|
|
7
46
|
## 1.3.2 (2020-06-16)
|
|
8
47
|
|
|
9
48
|
* Fixed: `nests_one` association record building used empty hash instead of passed in attributes. Credit to @chriscz.
|
|
10
49
|
|
|
50
|
+
|
|
11
51
|
## 1.3.1 (2020-03-31)
|
|
12
52
|
|
|
13
53
|
* Fixed: Avoid #change_association breaking for polymorphic associations. Thanks to @lucthev.
|
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,9 +55,9 @@ 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
|
|
|
56
62
|
BUNDLED WITH
|
|
57
|
-
2.
|
|
63
|
+
2.1.4
|
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)
|
|
@@ -54,4 +54,4 @@ DEPENDENCIES
|
|
|
54
54
|
sqlite3
|
|
55
55
|
|
|
56
56
|
BUNDLED WITH
|
|
57
|
-
2.
|
|
57
|
+
2.1.4
|
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,9 +53,9 @@ 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
|
|
|
60
60
|
BUNDLED WITH
|
|
61
|
-
2.
|
|
61
|
+
2.1.4
|
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)
|
|
@@ -58,4 +58,4 @@ DEPENDENCIES
|
|
|
58
58
|
rspec (~> 3.4)
|
|
59
59
|
|
|
60
60
|
BUNDLED WITH
|
|
61
|
-
2.
|
|
61
|
+
2.1.4
|
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)
|
|
@@ -58,4 +58,4 @@ DEPENDENCIES
|
|
|
58
58
|
sqlite3
|
|
59
59
|
|
|
60
60
|
BUNDLED WITH
|
|
61
|
-
2.
|
|
61
|
+
2.1.4
|
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.6.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.1.4
|
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.6.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
|
-
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.1.4
|
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.6.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.1.4
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
active_type (1.6.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.5.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.1.4
|
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.6.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.5.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.6
|
data/Gemfile.6.1.sqlite3
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
active_type (1.6.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.5.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.6
|
data/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
ActiveType [](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
|
|
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,
|
|
@@ -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
|
|
@@ -28,7 +28,32 @@ module ActiveType
|
|
|
28
28
|
module ClassMethods
|
|
29
29
|
|
|
30
30
|
def model_name
|
|
31
|
-
|
|
31
|
+
@_model_name ||= begin
|
|
32
|
+
if name
|
|
33
|
+
# Namespace detection copied from ActiveModel::Naming
|
|
34
|
+
namespace = module_ancestors.detect do |n|
|
|
35
|
+
n.respond_to?(:use_relative_model_naming?) && n.use_relative_model_naming?
|
|
36
|
+
end
|
|
37
|
+
# We create a Name object, with the parent class name, but self as the @klass reference
|
|
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, extended_record_base_class.name)
|
|
40
|
+
key = name.underscore
|
|
41
|
+
# We fake the `i18n_key` to lookup on the derived class key
|
|
42
|
+
# We keep the others the same to preserve parameter and route names
|
|
43
|
+
dup_model_name.define_singleton_method(:i18n_key) { key }
|
|
44
|
+
dup_model_name
|
|
45
|
+
else # name is nil for the anonymous intermediate class
|
|
46
|
+
extended_record_base_class.model_name
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def module_ancestors
|
|
52
|
+
if extended_record_base_class.respond_to?(:module_parents)
|
|
53
|
+
extended_record_base_class.module_parents
|
|
54
|
+
else
|
|
55
|
+
extended_record_base_class.parents
|
|
56
|
+
end
|
|
32
57
|
end
|
|
33
58
|
|
|
34
59
|
def sti_name
|
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
|
|
|
@@ -144,28 +161,53 @@ module ActiveType
|
|
|
144
161
|
@virtual_attributes_cache ||= {}
|
|
145
162
|
end
|
|
146
163
|
|
|
147
|
-
def
|
|
164
|
+
def read_existing_virtual_attribute(name, &block_when_not_virtual)
|
|
148
165
|
if self.singleton_class._has_virtual_column?(name)
|
|
149
166
|
read_virtual_attribute(name)
|
|
150
167
|
else
|
|
151
|
-
|
|
168
|
+
yield
|
|
152
169
|
end
|
|
153
170
|
end
|
|
154
171
|
|
|
155
|
-
|
|
156
|
-
def _read_attribute(name)
|
|
172
|
+
def write_existing_virtual_attribute(name, value, &block_when_not_virtual)
|
|
157
173
|
if self.singleton_class._has_virtual_column?(name)
|
|
158
|
-
|
|
174
|
+
write_virtual_attribute(name, value)
|
|
159
175
|
else
|
|
160
|
-
|
|
176
|
+
yield
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
def [](name)
|
|
181
|
+
read_existing_virtual_attribute(name) { super }
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
if ActiveRecord::VERSION::STRING >= '4.2.0'
|
|
185
|
+
def _read_attribute(name)
|
|
186
|
+
read_existing_virtual_attribute(name) { super }
|
|
187
|
+
end
|
|
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
|
|
192
|
+
def read_attribute(name)
|
|
193
|
+
read_existing_virtual_attribute(name) { super }
|
|
161
194
|
end
|
|
162
195
|
end
|
|
163
196
|
|
|
164
197
|
def []=(name, value)
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
198
|
+
write_existing_virtual_attribute(name, value) { super }
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
if ActiveRecord::VERSION::STRING >= '5.2.0'
|
|
202
|
+
def _write_attribute(name, value)
|
|
203
|
+
write_existing_virtual_attribute(name, value) { super }
|
|
204
|
+
end
|
|
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
|
|
209
|
+
def write_attribute(name, value)
|
|
210
|
+
write_existing_virtual_attribute(name, value) { super }
|
|
169
211
|
end
|
|
170
212
|
end
|
|
171
213
|
|
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.6.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-03-04 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
|
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.3.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.0.2
|