subroutine 4.1.5 → 4.2.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: 12ff37dae5fd328aaa0299e09ff2fe4827b98a3f59e0b4b6545a4b1176f834cf
4
- data.tar.gz: 95609b587580e37a859ca906dc9a7c767dc589a32a58a3a86f9c2b9e70a2c27c
3
+ metadata.gz: cc5cab16c1cf40e71f51c8572e1a9ecfe7ec0ff7bdabf8ebcae795bd4c30a4f3
4
+ data.tar.gz: bee1cf68aba104515cfd2917837d2574a12a61949f2602346da1e7a4d0b029a2
5
5
  SHA512:
6
- metadata.gz: 8d29b8e4f5cb1511974c339f28552f85da427bd146a273783abab7951a059b402d96e3fb53c52f8aa64d50bc1f174b103f5c183b4b35f94fc7f570de8e2330ba
7
- data.tar.gz: c144a73f6ff5dd51ad70ae3b1bc3d11aee020e9bc78a69805c40f1809e4597a9d51470d6974ef3259ac5975cde33d1c2beb5437985be12c116493d135b1e23a6
6
+ metadata.gz: fcb6f7393b6dfa6525cd344511321f4c3915696311230966ffdbb005128328b0e6d05ebf94b9088911c5d4abf17dd1988bd0d3deb013eaa81d517f1dfdd1c83b
7
+ data.tar.gz: 8ee46d11ded0b78432da1e86f7ebd05e30d9a54d55e53b3a336f074a294fc831444bef04381c0659a514c68f19bf6fef13dbd4ff46f321096d179360c10dcf95
@@ -10,7 +10,7 @@ jobs:
10
10
  strategy:
11
11
  fail-fast: false
12
12
  matrix:
13
- ruby-version: [3.0, 3.1, 3.2]
13
+ ruby-version: [3.0, 3.1, 3.2, 3.3]
14
14
  steps:
15
15
  - uses: actions/checkout@v4
16
16
  with:
data/CHANGELOG.MD CHANGED
@@ -1,3 +1,16 @@
1
+ # Changelog
2
+
3
+ ## Subroutine 4.2.0
4
+
5
+ If you are using polymorphic association fields, you can now customize how Subroutine
6
+ resolves those class names to a ruby class by setting a global callable/lambda/proc:
7
+
8
+ ```ruby
9
+ ::Subroutine.constantize_polymorphic_class_name = ->(class_name) do
10
+ class_name.classify.constantize
11
+ end
12
+ ```
13
+
1
14
  ## Subroutine 4.1.4
2
15
 
3
16
  Fields using the time/timestamp/datetime caster will now default back to the old behavior, and use a `precision:` option to opt-in to the new behavior introduced in `v4.1.1`.
@@ -16,7 +29,7 @@ to string and re-parsing to a Time object. This fixes issues with losing usec pr
16
29
 
17
30
  ## Subroutine 4.1.0
18
31
 
19
- A field can no opt out of the natural assignment behavior of ActiveSupport::HashWithIndifferentAccess. Top level param groups are still accessible via indifferent access but if a field sets the `bypass_indifferent_assignment` option to `true` the HashWithIndifferentAccess assignment behavior will be bypassed in favor of direct Hash-like assignment.
32
+ A field can now opt out of the natural assignment behavior of ActiveSupport::HashWithIndifferentAccess. Top level param groups are still accessible via indifferent access but if a field sets the `bypass_indifferent_assignment` option to `true` the HashWithIndifferentAccess assignment behavior will be bypassed in favor of direct Hash-like assignment.
20
33
 
21
34
  ```ruby
22
35
  class MyOp < Subroutine::Op
@@ -37,6 +50,9 @@ The `Subroutine::Fields` module now contains a class_attribute that allows the a
37
50
 
38
51
  Removed all usage of `ungrouped` params and refactored the storage of grouped params. Params are now stored in either the provided group or the defaults group and accessed via provided_params, params, default_params, and params_with_defaults. Grouped params are accessed the same way but with the group name prefixed eg. `my_private_default_params`.
39
52
 
53
+ Polymorphic association fields now resolve class names via `klass.camelize.constantize`,
54
+ previously was `klass.classify.constantize`.
55
+
40
56
  ## Subroutine 3.0
41
57
 
42
58
  Add support for Rails 6.1. Drop support for Rails 6.0 and lower.
@@ -1,29 +1,29 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- subroutine (4.1.0)
4
+ subroutine (4.2.0)
5
5
  activemodel (>= 6.1)
6
6
  activesupport (>= 6.1)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- actionpack (6.1.7.8)
12
- actionview (= 6.1.7.8)
13
- activesupport (= 6.1.7.8)
11
+ actionpack (6.1.7.10)
12
+ actionview (= 6.1.7.10)
13
+ activesupport (= 6.1.7.10)
14
14
  rack (~> 2.0, >= 2.0.9)
15
15
  rack-test (>= 0.6.3)
16
16
  rails-dom-testing (~> 2.0)
17
17
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
18
- actionview (6.1.7.8)
19
- activesupport (= 6.1.7.8)
18
+ actionview (6.1.7.10)
19
+ activesupport (= 6.1.7.10)
20
20
  builder (~> 3.1)
21
21
  erubi (~> 1.4)
22
22
  rails-dom-testing (~> 2.0)
23
23
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
24
- activemodel (6.1.7.8)
25
- activesupport (= 6.1.7.8)
26
- activesupport (6.1.7.8)
24
+ activemodel (6.1.7.10)
25
+ activesupport (= 6.1.7.10)
26
+ activesupport (6.1.7.10)
27
27
  concurrent-ruby (~> 1.0, >= 1.0.2)
28
28
  i18n (>= 1.6, < 2)
29
29
  minitest (>= 5.1)
@@ -41,43 +41,43 @@ GEM
41
41
  erubi (1.13.0)
42
42
  i18n (1.14.6)
43
43
  concurrent-ruby (~> 1.0)
44
- loofah (2.22.0)
44
+ loofah (2.23.1)
45
45
  crass (~> 1.0.2)
46
46
  nokogiri (>= 1.12.0)
47
47
  m (1.6.2)
48
48
  method_source (>= 0.6.7)
49
49
  rake (>= 0.9.2.2)
50
50
  method_source (1.1.0)
51
- mini_portile2 (2.8.7)
52
- minitest (5.25.1)
51
+ mini_portile2 (2.8.8)
52
+ minitest (5.25.4)
53
53
  minitest-reporters (1.7.1)
54
54
  ansi
55
55
  builder
56
56
  minitest (>= 5.0)
57
57
  ruby-progressbar
58
- mocha (2.4.5)
58
+ mocha (2.7.1)
59
59
  ruby2_keywords (>= 0.0.5)
60
- nokogiri (1.16.7)
60
+ nokogiri (1.17.2)
61
61
  mini_portile2 (~> 2.8.2)
62
62
  racc (~> 1.4)
63
63
  racc (1.8.1)
64
- rack (2.2.9)
64
+ rack (2.2.10)
65
65
  rack-test (2.1.0)
66
66
  rack (>= 1.3)
67
67
  rails-dom-testing (2.2.0)
68
68
  activesupport (>= 5.0.0)
69
69
  minitest
70
70
  nokogiri (>= 1.6)
71
- rails-html-sanitizer (1.6.0)
71
+ rails-html-sanitizer (1.6.2)
72
72
  loofah (~> 2.21)
73
- nokogiri (~> 1.14)
73
+ nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
74
74
  rake (13.2.1)
75
75
  ruby-progressbar (1.13.0)
76
76
  ruby2_keywords (0.0.5)
77
77
  thor (1.3.2)
78
78
  tzinfo (2.0.6)
79
79
  concurrent-ruby (~> 1.0)
80
- zeitwerk (2.6.18)
80
+ zeitwerk (2.7.1)
81
81
 
82
82
  PLATFORMS
83
83
  ruby
@@ -1,29 +1,29 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- subroutine (4.1.0)
4
+ subroutine (4.2.0)
5
5
  activemodel (>= 6.1)
6
6
  activesupport (>= 6.1)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- actionpack (7.0.8.4)
12
- actionview (= 7.0.8.4)
13
- activesupport (= 7.0.8.4)
11
+ actionpack (7.0.8.7)
12
+ actionview (= 7.0.8.7)
13
+ activesupport (= 7.0.8.7)
14
14
  rack (~> 2.0, >= 2.2.4)
15
15
  rack-test (>= 0.6.3)
16
16
  rails-dom-testing (~> 2.0)
17
17
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
18
- actionview (7.0.8.4)
19
- activesupport (= 7.0.8.4)
18
+ actionview (7.0.8.7)
19
+ activesupport (= 7.0.8.7)
20
20
  builder (~> 3.1)
21
21
  erubi (~> 1.4)
22
22
  rails-dom-testing (~> 2.0)
23
23
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
24
- activemodel (7.0.8.4)
25
- activesupport (= 7.0.8.4)
26
- activesupport (7.0.8.4)
24
+ activemodel (7.0.8.7)
25
+ activesupport (= 7.0.8.7)
26
+ activesupport (7.0.8.7)
27
27
  concurrent-ruby (~> 1.0, >= 1.0.2)
28
28
  i18n (>= 1.6, < 2)
29
29
  minitest (>= 5.1)
@@ -40,36 +40,36 @@ GEM
40
40
  erubi (1.13.0)
41
41
  i18n (1.14.6)
42
42
  concurrent-ruby (~> 1.0)
43
- loofah (2.22.0)
43
+ loofah (2.23.1)
44
44
  crass (~> 1.0.2)
45
45
  nokogiri (>= 1.12.0)
46
46
  m (1.6.2)
47
47
  method_source (>= 0.6.7)
48
48
  rake (>= 0.9.2.2)
49
49
  method_source (1.1.0)
50
- mini_portile2 (2.8.7)
51
- minitest (5.25.1)
50
+ mini_portile2 (2.8.8)
51
+ minitest (5.25.4)
52
52
  minitest-reporters (1.7.1)
53
53
  ansi
54
54
  builder
55
55
  minitest (>= 5.0)
56
56
  ruby-progressbar
57
- mocha (2.4.5)
57
+ mocha (2.7.1)
58
58
  ruby2_keywords (>= 0.0.5)
59
- nokogiri (1.16.7)
59
+ nokogiri (1.17.2)
60
60
  mini_portile2 (~> 2.8.2)
61
61
  racc (~> 1.4)
62
62
  racc (1.8.1)
63
- rack (2.2.9)
63
+ rack (2.2.10)
64
64
  rack-test (2.1.0)
65
65
  rack (>= 1.3)
66
66
  rails-dom-testing (2.2.0)
67
67
  activesupport (>= 5.0.0)
68
68
  minitest
69
69
  nokogiri (>= 1.6)
70
- rails-html-sanitizer (1.6.0)
70
+ rails-html-sanitizer (1.6.2)
71
71
  loofah (~> 2.21)
72
- nokogiri (~> 1.14)
72
+ nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
73
73
  rake (13.2.1)
74
74
  ruby-progressbar (1.13.0)
75
75
  ruby2_keywords (0.0.5)
@@ -1,16 +1,16 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- subroutine (4.1.0)
4
+ subroutine (4.2.0)
5
5
  activemodel (>= 6.1)
6
6
  activesupport (>= 6.1)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- actionpack (7.1.4)
12
- actionview (= 7.1.4)
13
- activesupport (= 7.1.4)
11
+ actionpack (7.1.5.1)
12
+ actionview (= 7.1.5.1)
13
+ activesupport (= 7.1.5.1)
14
14
  nokogiri (>= 1.8.5)
15
15
  racc
16
16
  rack (>= 2.2.4)
@@ -18,23 +18,26 @@ GEM
18
18
  rack-test (>= 0.6.3)
19
19
  rails-dom-testing (~> 2.2)
20
20
  rails-html-sanitizer (~> 1.6)
21
- actionview (7.1.4)
22
- activesupport (= 7.1.4)
21
+ actionview (7.1.5.1)
22
+ activesupport (= 7.1.5.1)
23
23
  builder (~> 3.1)
24
24
  erubi (~> 1.11)
25
25
  rails-dom-testing (~> 2.2)
26
26
  rails-html-sanitizer (~> 1.6)
27
- activemodel (7.1.4)
28
- activesupport (= 7.1.4)
29
- activesupport (7.1.4)
27
+ activemodel (7.1.5.1)
28
+ activesupport (= 7.1.5.1)
29
+ activesupport (7.1.5.1)
30
30
  base64
31
+ benchmark (>= 0.3)
31
32
  bigdecimal
32
33
  concurrent-ruby (~> 1.0, >= 1.0.2)
33
34
  connection_pool (>= 2.2.5)
34
35
  drb
35
36
  i18n (>= 1.6, < 2)
37
+ logger (>= 1.4.2)
36
38
  minitest (>= 5.1)
37
39
  mutex_m
40
+ securerandom (>= 0.3)
38
41
  tzinfo (~> 2.0)
39
42
  ansi (1.5.0)
40
43
  appraisal (2.5.0)
@@ -42,6 +45,7 @@ GEM
42
45
  rake
43
46
  thor (>= 0.14.0)
44
47
  base64 (0.2.0)
48
+ benchmark (0.4.0)
45
49
  bigdecimal (3.1.8)
46
50
  builder (3.3.0)
47
51
  byebug (11.1.3)
@@ -52,26 +56,27 @@ GEM
52
56
  erubi (1.13.0)
53
57
  i18n (1.14.6)
54
58
  concurrent-ruby (~> 1.0)
55
- loofah (2.22.0)
59
+ logger (1.6.3)
60
+ loofah (2.23.1)
56
61
  crass (~> 1.0.2)
57
62
  nokogiri (>= 1.12.0)
58
63
  m (1.6.2)
59
64
  method_source (>= 0.6.7)
60
65
  rake (>= 0.9.2.2)
61
66
  method_source (1.1.0)
62
- minitest (5.25.1)
67
+ minitest (5.25.4)
63
68
  minitest-reporters (1.7.1)
64
69
  ansi
65
70
  builder
66
71
  minitest (>= 5.0)
67
72
  ruby-progressbar
68
- mocha (2.4.5)
73
+ mocha (2.7.1)
69
74
  ruby2_keywords (>= 0.0.5)
70
- mutex_m (0.2.0)
71
- nokogiri (1.16.7-arm64-darwin)
75
+ mutex_m (0.3.0)
76
+ nokogiri (1.17.2-arm64-darwin)
72
77
  racc (~> 1.4)
73
78
  racc (1.8.1)
74
- rack (3.1.7)
79
+ rack (3.1.8)
75
80
  rack-session (2.0.0)
76
81
  rack (>= 3.0.0)
77
82
  rack-test (2.1.0)
@@ -80,12 +85,13 @@ GEM
80
85
  activesupport (>= 5.0.0)
81
86
  minitest
82
87
  nokogiri (>= 1.6)
83
- rails-html-sanitizer (1.6.0)
88
+ rails-html-sanitizer (1.6.2)
84
89
  loofah (~> 2.21)
85
- nokogiri (~> 1.14)
90
+ nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
86
91
  rake (13.2.1)
87
92
  ruby-progressbar (1.13.0)
88
93
  ruby2_keywords (0.0.5)
94
+ securerandom (0.4.0)
89
95
  thor (1.3.2)
90
96
  tzinfo (2.0.6)
91
97
  concurrent-ruby (~> 1.0)
@@ -1,16 +1,16 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- subroutine (4.1.0)
4
+ subroutine (4.2.0)
5
5
  activemodel (>= 6.1)
6
6
  activesupport (>= 6.1)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- actionpack (7.2.1)
12
- actionview (= 7.2.1)
13
- activesupport (= 7.2.1)
11
+ actionpack (7.2.2.1)
12
+ actionview (= 7.2.2.1)
13
+ activesupport (= 7.2.2.1)
14
14
  nokogiri (>= 1.8.5)
15
15
  racc
16
16
  rack (>= 2.2.4, < 3.2)
@@ -19,16 +19,17 @@ GEM
19
19
  rails-dom-testing (~> 2.2)
20
20
  rails-html-sanitizer (~> 1.6)
21
21
  useragent (~> 0.16)
22
- actionview (7.2.1)
23
- activesupport (= 7.2.1)
22
+ actionview (7.2.2.1)
23
+ activesupport (= 7.2.2.1)
24
24
  builder (~> 3.1)
25
25
  erubi (~> 1.11)
26
26
  rails-dom-testing (~> 2.2)
27
27
  rails-html-sanitizer (~> 1.6)
28
- activemodel (7.2.1)
29
- activesupport (= 7.2.1)
30
- activesupport (7.2.1)
28
+ activemodel (7.2.2.1)
29
+ activesupport (= 7.2.2.1)
30
+ activesupport (7.2.2.1)
31
31
  base64
32
+ benchmark (>= 0.3)
32
33
  bigdecimal
33
34
  concurrent-ruby (~> 1.0, >= 1.3.1)
34
35
  connection_pool (>= 2.2.5)
@@ -44,6 +45,7 @@ GEM
44
45
  rake
45
46
  thor (>= 0.14.0)
46
47
  base64 (0.2.0)
48
+ benchmark (0.4.0)
47
49
  bigdecimal (3.1.8)
48
50
  builder (3.3.0)
49
51
  byebug (11.1.3)
@@ -54,26 +56,26 @@ GEM
54
56
  erubi (1.13.0)
55
57
  i18n (1.14.6)
56
58
  concurrent-ruby (~> 1.0)
57
- logger (1.6.1)
58
- loofah (2.22.0)
59
+ logger (1.6.3)
60
+ loofah (2.23.1)
59
61
  crass (~> 1.0.2)
60
62
  nokogiri (>= 1.12.0)
61
63
  m (1.6.2)
62
64
  method_source (>= 0.6.7)
63
65
  rake (>= 0.9.2.2)
64
66
  method_source (1.1.0)
65
- minitest (5.25.1)
67
+ minitest (5.25.4)
66
68
  minitest-reporters (1.7.1)
67
69
  ansi
68
70
  builder
69
71
  minitest (>= 5.0)
70
72
  ruby-progressbar
71
- mocha (2.4.5)
73
+ mocha (2.7.1)
72
74
  ruby2_keywords (>= 0.0.5)
73
- nokogiri (1.16.7-arm64-darwin)
75
+ nokogiri (1.17.2-arm64-darwin)
74
76
  racc (~> 1.4)
75
77
  racc (1.8.1)
76
- rack (3.1.7)
78
+ rack (3.1.8)
77
79
  rack-session (2.0.0)
78
80
  rack (>= 3.0.0)
79
81
  rack-test (2.1.0)
@@ -82,17 +84,17 @@ GEM
82
84
  activesupport (>= 5.0.0)
83
85
  minitest
84
86
  nokogiri (>= 1.6)
85
- rails-html-sanitizer (1.6.0)
87
+ rails-html-sanitizer (1.6.2)
86
88
  loofah (~> 2.21)
87
- nokogiri (~> 1.14)
89
+ nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
88
90
  rake (13.2.1)
89
91
  ruby-progressbar (1.13.0)
90
92
  ruby2_keywords (0.0.5)
91
- securerandom (0.3.1)
93
+ securerandom (0.4.0)
92
94
  thor (1.3.2)
93
95
  tzinfo (2.0.6)
94
96
  concurrent-ruby (~> 1.0)
95
- useragent (0.16.10)
97
+ useragent (0.16.11)
96
98
 
97
99
  PLATFORMS
98
100
  arm64-darwin
@@ -177,7 +177,7 @@ module Subroutine
177
177
  get_field(config.foreign_type_method)
178
178
  end
179
179
 
180
- klass = klass.camelize.constantize if klass.is_a?(String)
180
+ klass = Subroutine.constantize_polymorphic_class_name(klass) if klass.is_a?(String)
181
181
  return nil unless klass
182
182
 
183
183
  foreign_key = config.foreign_key_method
@@ -3,8 +3,8 @@
3
3
  module Subroutine
4
4
 
5
5
  MAJOR = 4
6
- MINOR = 1
7
- PATCH = 5
6
+ MINOR = 2
7
+ PATCH = 0
8
8
  PRE = nil
9
9
 
10
10
  VERSION = [MAJOR, MINOR, PATCH, PRE].compact.join(".")
data/lib/subroutine.rb CHANGED
@@ -16,6 +16,18 @@ require "subroutine/op"
16
16
 
17
17
  module Subroutine
18
18
 
19
+ # Used by polymorphic association fields to resolve the class name to a ruby class
20
+ def self.constantize_polymorphic_class_name(class_name)
21
+ return @constantize_polymorphic_class_name.call(class_name) if defined?(@constantize_polymorphic_class_name)
22
+
23
+ class_name.camelize.constantize
24
+ end
25
+
26
+ # When you need to customize how a polymorphic class name is resolved, you can set this callable/lambda/proc
27
+ def self.constantize_polymorphic_class_name=(callable)
28
+ @constantize_polymorphic_class_name = callable
29
+ end
30
+
19
31
  def self.include_defaults_in_params=(bool)
20
32
  @include_defaults_in_params = !!bool
21
33
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: subroutine
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.5
4
+ version: 4.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Nelson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-11-22 00:00:00.000000000 Z
11
+ date: 2024-12-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel