active_type 1.6.0 → 1.7.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 +38 -53
- data/Gemfile.5.2.mysql2.lock +1 -1
- data/Gemfile.5.2.pg.lock +3 -3
- data/Gemfile.5.2.sqlite3.lock +2 -2
- data/Gemfile.6.0.sqlite3.lock +3 -3
- data/Gemfile.6.1.pg.lock +3 -3
- data/Gemfile.6.1.sqlite3.lock +3 -3
- data/README.md +15 -4
- data/lib/active_type/change_association.rb +2 -2
- data/lib/active_type/record_extension/inheritance.rb +15 -5
- data/lib/active_type/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc1d824f4bc8d16a858ad4264432940368081f7ff9dac1e6ab522e7a8e244385
|
4
|
+
data.tar.gz: 62a451171a9caab0a89901856746262cb0529b7b94df191baa7ee9d01a13a6e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e9899a9e91e7150fb56a9a3e745c86966122f596b9ebe72ee23136c232fd8e77db9f9b670a13980021e57fd46dc8f8f46d899bf9fb7faa20ef261558eb44929
|
7
|
+
data.tar.gz: 66c4878918cb20e924f0c044e1ae6d862611622067eaca2608ce25caa1a67d081416a69e5e10a83dd4ce256c306cbea624860d3f699d53be5da8d0ecf21b3c15
|
data/.github/workflows/test.yml
CHANGED
@@ -13,34 +13,35 @@ jobs:
|
|
13
13
|
strategy:
|
14
14
|
fail-fast: false
|
15
15
|
matrix:
|
16
|
-
|
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:
|
16
|
+
include:
|
28
17
|
- ruby: "2.3.8"
|
29
|
-
gemfile: Gemfile.
|
18
|
+
gemfile: Gemfile.3.2.sqlite3
|
30
19
|
- ruby: "2.3.8"
|
31
|
-
gemfile: Gemfile.
|
20
|
+
gemfile: Gemfile.4.2.sqlite3
|
21
|
+
- ruby: "2.3.8"
|
22
|
+
gemfile: Gemfile.5.2.sqlite3
|
32
23
|
- ruby: "2.5.5"
|
33
|
-
gemfile: Gemfile.
|
24
|
+
gemfile: Gemfile.5.2.sqlite3
|
34
25
|
- ruby: "2.5.5"
|
35
|
-
gemfile: Gemfile.
|
26
|
+
gemfile: Gemfile.6.0.sqlite3
|
27
|
+
- ruby: "2.5.5"
|
28
|
+
gemfile: Gemfile.6.1.sqlite3
|
36
29
|
- ruby: "2.6.3"
|
37
|
-
gemfile: Gemfile.
|
30
|
+
gemfile: Gemfile.5.2.sqlite3
|
38
31
|
- ruby: "2.6.3"
|
39
|
-
gemfile: Gemfile.
|
32
|
+
gemfile: Gemfile.6.0.sqlite3
|
33
|
+
- ruby: "2.6.3"
|
34
|
+
gemfile: Gemfile.6.1.sqlite3
|
40
35
|
- ruby: "2.7.2"
|
41
|
-
gemfile: Gemfile.
|
36
|
+
gemfile: Gemfile.5.2.sqlite3
|
42
37
|
- ruby: "2.7.2"
|
43
|
-
gemfile: Gemfile.
|
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
|
44
45
|
|
45
46
|
env:
|
46
47
|
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
|
@@ -78,30 +79,17 @@ jobs:
|
|
78
79
|
strategy:
|
79
80
|
fail-fast: false
|
80
81
|
matrix:
|
81
|
-
|
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"
|
82
|
+
include:
|
83
|
+
- ruby: "2.3.8"
|
92
84
|
gemfile: Gemfile.3.2.mysql2
|
93
|
-
- ruby: "2.
|
85
|
+
- ruby: "2.3.8"
|
94
86
|
gemfile: Gemfile.4.2.mysql2
|
95
|
-
- ruby: "2.
|
87
|
+
- ruby: "2.3.8"
|
96
88
|
gemfile: Gemfile.5.2.mysql2
|
97
89
|
- ruby: "2.6.3"
|
98
|
-
gemfile: Gemfile.
|
99
|
-
- ruby: "2.6.3"
|
100
|
-
gemfile: Gemfile.4.2.mysql2
|
101
|
-
- ruby: "2.7.2"
|
102
|
-
gemfile: Gemfile.3.2.mysql2
|
90
|
+
gemfile: Gemfile.5.2.mysql2
|
103
91
|
- ruby: "2.7.2"
|
104
|
-
gemfile: Gemfile.
|
92
|
+
gemfile: Gemfile.5.2.mysql2
|
105
93
|
|
106
94
|
env:
|
107
95
|
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
|
@@ -146,26 +134,23 @@ jobs:
|
|
146
134
|
strategy:
|
147
135
|
fail-fast: false
|
148
136
|
matrix:
|
149
|
-
|
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:
|
137
|
+
include:
|
159
138
|
- ruby: "2.3.8"
|
160
|
-
gemfile: Gemfile.6.1.pg
|
161
|
-
- ruby: "2.5.5"
|
162
139
|
gemfile: Gemfile.4.2.pg
|
140
|
+
- ruby: "2.3.8"
|
141
|
+
gemfile: Gemfile.5.2.pg
|
163
142
|
- ruby: "2.5.5"
|
143
|
+
gemfile: Gemfile.6.1.pg
|
144
|
+
- ruby: "2.6.3"
|
164
145
|
gemfile: Gemfile.5.2.pg
|
165
146
|
- ruby: "2.6.3"
|
166
|
-
gemfile: Gemfile.
|
147
|
+
gemfile: Gemfile.6.1.pg
|
167
148
|
- ruby: "2.7.2"
|
168
|
-
gemfile: Gemfile.
|
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
|
169
154
|
|
170
155
|
env:
|
171
156
|
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
|
data/Gemfile.5.2.mysql2.lock
CHANGED
data/Gemfile.5.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.7.0)
|
5
5
|
activerecord (>= 3.2)
|
6
6
|
|
7
7
|
GEM
|
@@ -21,7 +21,7 @@ GEM
|
|
21
21
|
arel (8.0.0)
|
22
22
|
concurrent-ruby (1.1.7)
|
23
23
|
diff-lcs (1.4.4)
|
24
|
-
gemika (0.
|
24
|
+
gemika (0.6.0)
|
25
25
|
i18n (1.8.5)
|
26
26
|
concurrent-ruby (~> 1.0)
|
27
27
|
minitest (5.14.2)
|
@@ -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
data/Gemfile.6.0.sqlite3.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
active_type (1.
|
4
|
+
active_type (1.7.0)
|
5
5
|
activerecord (>= 3.2)
|
6
6
|
|
7
7
|
GEM
|
@@ -20,7 +20,7 @@ GEM
|
|
20
20
|
zeitwerk (~> 2.2, >= 2.2.2)
|
21
21
|
concurrent-ruby (1.1.7)
|
22
22
|
diff-lcs (1.4.4)
|
23
|
-
gemika (0.
|
23
|
+
gemika (0.6.0)
|
24
24
|
i18n (1.8.5)
|
25
25
|
concurrent-ruby (~> 1.0)
|
26
26
|
minitest (5.14.2)
|
@@ -56,4 +56,4 @@ DEPENDENCIES
|
|
56
56
|
sqlite3
|
57
57
|
|
58
58
|
BUNDLED WITH
|
59
|
-
2.
|
59
|
+
2.2.16
|
data/Gemfile.6.1.pg.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
active_type (1.
|
4
|
+
active_type (1.7.0)
|
5
5
|
activerecord (>= 3.2)
|
6
6
|
|
7
7
|
GEM
|
@@ -20,7 +20,7 @@ GEM
|
|
20
20
|
zeitwerk (~> 2.3)
|
21
21
|
concurrent-ruby (1.1.8)
|
22
22
|
diff-lcs (1.4.4)
|
23
|
-
gemika (0.
|
23
|
+
gemika (0.6.0)
|
24
24
|
i18n (1.8.9)
|
25
25
|
concurrent-ruby (~> 1.0)
|
26
26
|
minitest (5.14.4)
|
@@ -55,4 +55,4 @@ DEPENDENCIES
|
|
55
55
|
rspec (~> 3.4)
|
56
56
|
|
57
57
|
BUNDLED WITH
|
58
|
-
2.2.
|
58
|
+
2.2.16
|
data/Gemfile.6.1.sqlite3.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
active_type (1.
|
4
|
+
active_type (1.7.0)
|
5
5
|
activerecord (>= 3.2)
|
6
6
|
|
7
7
|
GEM
|
@@ -20,7 +20,7 @@ GEM
|
|
20
20
|
zeitwerk (~> 2.3)
|
21
21
|
concurrent-ruby (1.1.8)
|
22
22
|
diff-lcs (1.4.4)
|
23
|
-
gemika (0.
|
23
|
+
gemika (0.6.0)
|
24
24
|
i18n (1.8.9)
|
25
25
|
concurrent-ruby (~> 1.0)
|
26
26
|
minitest (5.14.4)
|
@@ -55,4 +55,4 @@ DEPENDENCIES
|
|
55
55
|
sqlite3
|
56
56
|
|
57
57
|
BUNDLED WITH
|
58
|
-
2.2.
|
58
|
+
2.2.16
|
data/README.md
CHANGED
@@ -129,7 +129,7 @@ Virtual attributes will not be persisted.
|
|
129
129
|
|
130
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.
|
131
131
|
|
132
|
-
|
132
|
+
Your class will inherit from `BaseClass`. You can add additional methods, validations, callbacks, as well as use (virtual) attributes like an `ActiveType::Object`:
|
133
133
|
|
134
134
|
```ruby
|
135
135
|
class SignUp < ActiveType::Record[User]
|
@@ -137,6 +137,17 @@ class SignUp < ActiveType::Record[User]
|
|
137
137
|
end
|
138
138
|
```
|
139
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
|
+
|
140
151
|
### Inheriting from ActiveType:: objects
|
141
152
|
|
142
153
|
If you want to inherit from an ActiveType class, simply do
|
@@ -394,14 +405,14 @@ Now, if you load `credentials`, you will automatically receive records of type `
|
|
394
405
|
Supported Rails versions
|
395
406
|
------------------------
|
396
407
|
|
397
|
-
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.
|
398
409
|
|
399
410
|
Later versions might work, earlier will not.
|
400
411
|
|
401
412
|
Supported Ruby versions
|
402
413
|
------------------------
|
403
414
|
|
404
|
-
ActiveType is tested against 2.3, 2.4,
|
415
|
+
ActiveType is tested against 2.3, 2.4, 2.5 and 3.0.
|
405
416
|
|
406
417
|
|
407
418
|
Installation
|
@@ -429,7 +440,7 @@ If you would like to contribute:
|
|
429
440
|
- Push your changes **with passing specs**.
|
430
441
|
- Send us a pull request.
|
431
442
|
|
432
|
-
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).
|
433
444
|
|
434
445
|
|
435
446
|
Credits
|
@@ -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}`"
|
@@ -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
|
@@ -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/version.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: 1.
|
4
|
+
version: 1.7.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: 2021-
|
12
|
+
date: 2021-04-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|