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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fd106690815f11c7582797456d2915ae313899725bfab18aa1ada385c66367cc
4
- data.tar.gz: 1aec1dec85d519dfa8d75ae3985e1e182963725369c783eb8b2254f6406bba97
3
+ metadata.gz: fc1d824f4bc8d16a858ad4264432940368081f7ff9dac1e6ab522e7a8e244385
4
+ data.tar.gz: 62a451171a9caab0a89901856746262cb0529b7b94df191baa7ee9d01a13a6e9
5
5
  SHA512:
6
- metadata.gz: 611573072b7632eec3d78e7a80263ff4844100b2c401879fbbfe326d8d68cf2f3780fdaa7c260f8917aaadbe343f263472c12a42a797d6dbead714540df2a5bb
7
- data.tar.gz: 6a0e49c446ada6f2a63cad98ab59ab552015e3fe3c573fe4075ba28f0ddb02b084cb5b604f005da6f99bad2221e8dfdc9c3d6f90963bd6142a62525b0c5af39c
6
+ metadata.gz: 8e9899a9e91e7150fb56a9a3e745c86966122f596b9ebe72ee23136c232fd8e77db9f9b670a13980021e57fd46dc8f8f46d899bf9fb7faa20ef261558eb44929
7
+ data.tar.gz: 66c4878918cb20e924f0c044e1ae6d862611622067eaca2608ce25caa1a67d081416a69e5e10a83dd4ce256c306cbea624860d3f699d53be5da8d0ecf21b3c15
@@ -13,34 +13,35 @@ jobs:
13
13
  strategy:
14
14
  fail-fast: false
15
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:
16
+ include:
28
17
  - ruby: "2.3.8"
29
- gemfile: Gemfile.6.0.sqlite3
18
+ gemfile: Gemfile.3.2.sqlite3
30
19
  - ruby: "2.3.8"
31
- gemfile: Gemfile.6.1.sqlite3
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.3.2.sqlite3
24
+ gemfile: Gemfile.5.2.sqlite3
34
25
  - ruby: "2.5.5"
35
- gemfile: Gemfile.4.2.sqlite3
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.3.2.sqlite3
30
+ gemfile: Gemfile.5.2.sqlite3
38
31
  - ruby: "2.6.3"
39
- gemfile: Gemfile.4.2.sqlite3
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.3.2.sqlite3
36
+ gemfile: Gemfile.5.2.sqlite3
42
37
  - ruby: "2.7.2"
43
- gemfile: Gemfile.4.2.sqlite3
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
- 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"
82
+ include:
83
+ - ruby: "2.3.8"
92
84
  gemfile: Gemfile.3.2.mysql2
93
- - ruby: "2.5.5"
85
+ - ruby: "2.3.8"
94
86
  gemfile: Gemfile.4.2.mysql2
95
- - ruby: "2.5.5"
87
+ - ruby: "2.3.8"
96
88
  gemfile: Gemfile.5.2.mysql2
97
89
  - 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
90
+ gemfile: Gemfile.5.2.mysql2
103
91
  - ruby: "2.7.2"
104
- gemfile: Gemfile.4.2.mysql2
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
- 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:
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.4.2.pg
147
+ gemfile: Gemfile.6.1.pg
167
148
  - ruby: "2.7.2"
168
- gemfile: Gemfile.4.2.pg
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 }}
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active_type (1.6.0)
4
+ active_type (1.7.0)
5
5
  activerecord (>= 3.2)
6
6
 
7
7
  GEM
data/Gemfile.5.2.pg.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active_type (1.6.0)
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.5.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.1.4
59
+ 2.2.16
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active_type (1.6.0)
4
+ active_type (1.7.0)
5
5
  activerecord (>= 3.2)
6
6
 
7
7
  GEM
@@ -56,4 +56,4 @@ DEPENDENCIES
56
56
  sqlite3
57
57
 
58
58
  BUNDLED WITH
59
- 2.1.4
59
+ 2.2.16
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active_type (1.6.0)
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.5.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.1.4
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.6.0)
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.5.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.6
58
+ 2.2.16
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- active_type (1.6.0)
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.5.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.6
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
- You class will inherit from `BaseClass`. You can add additional methods, validations, callbacks, as well as use (virtual) attributes like an `ActiveType::Object`:
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, and 5.2.
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, and 2.5.
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 leightweight 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).
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
- [scope, options]
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
- super(name, *Inheritance.add_foreign_key_option(extended_record_base_class, *args), &extension)
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
- super(name, *Inheritance.add_foreign_key_option(extended_record_base_class, *args), &extension)
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
@@ -1,3 +1,3 @@
1
1
  module ActiveType
2
- VERSION = '1.6.0'
2
+ VERSION = '1.7.0'
3
3
  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.6.0
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-03-04 00:00:00.000000000 Z
12
+ date: 2021-04-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler