active_type 1.4.0 → 1.7.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 +175 -0
- data/CHANGELOG.md +17 -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 +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 +24 -6
- data/lib/active_type/version.rb +1 -1
- data/lib/active_type/virtual_attributes.rb +53 -11
- metadata +10 -6
- data/.travis.yml +0 -72
- data/Gemfile.6.0.pg.lock +0 -59
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.7.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.7.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.7.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.7.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.7.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/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
|
|
@@ -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,
|