subroutine 4.1.4 → 4.2.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/build.yml +1 -1
- data/CHANGELOG.MD +17 -1
- data/gemfiles/rails_6.1.gemfile.lock +18 -18
- data/gemfiles/rails_7.0.gemfile.lock +17 -17
- data/gemfiles/rails_7.1.gemfile.lock +23 -17
- data/gemfiles/rails_7.2.gemfile.lock +21 -19
- data/lib/subroutine/association_fields.rb +1 -1
- data/lib/subroutine/type_caster.rb +11 -15
- data/lib/subroutine/version.rb +2 -2
- data/lib/subroutine.rb +23 -0
- data/test/subroutine/type_caster_test.rb +17 -3
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cc5cab16c1cf40e71f51c8572e1a9ecfe7ec0ff7bdabf8ebcae795bd4c30a4f3
|
|
4
|
+
data.tar.gz: bee1cf68aba104515cfd2917837d2574a12a61949f2602346da1e7a4d0b029a2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fcb6f7393b6dfa6525cd344511321f4c3915696311230966ffdbb005128328b0e6d05ebf94b9088911c5d4abf17dd1988bd0d3deb013eaa81d517f1dfdd1c83b
|
|
7
|
+
data.tar.gz: 8ee46d11ded0b78432da1e86f7ebd05e30d9a54d55e53b3a336f074a294fc831444bef04381c0659a514c68f19bf6fef13dbd4ff46f321096d179360c10dcf95
|
data/.github/workflows/build.yml
CHANGED
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
|
|
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.
|
|
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.
|
|
12
|
-
actionview (= 6.1.7.
|
|
13
|
-
activesupport (= 6.1.7.
|
|
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.
|
|
19
|
-
activesupport (= 6.1.7.
|
|
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.
|
|
25
|
-
activesupport (= 6.1.7.
|
|
26
|
-
activesupport (6.1.7.
|
|
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.
|
|
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.
|
|
52
|
-
minitest (5.25.
|
|
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.
|
|
58
|
+
mocha (2.7.1)
|
|
59
59
|
ruby2_keywords (>= 0.0.5)
|
|
60
|
-
nokogiri (1.
|
|
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.
|
|
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.
|
|
71
|
+
rails-html-sanitizer (1.6.2)
|
|
72
72
|
loofah (~> 2.21)
|
|
73
|
-
nokogiri (
|
|
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.
|
|
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.
|
|
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.
|
|
12
|
-
actionview (= 7.0.8.
|
|
13
|
-
activesupport (= 7.0.8.
|
|
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.
|
|
19
|
-
activesupport (= 7.0.8.
|
|
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.
|
|
25
|
-
activesupport (= 7.0.8.
|
|
26
|
-
activesupport (7.0.8.
|
|
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.
|
|
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.
|
|
51
|
-
minitest (5.25.
|
|
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.
|
|
57
|
+
mocha (2.7.1)
|
|
58
58
|
ruby2_keywords (>= 0.0.5)
|
|
59
|
-
nokogiri (1.
|
|
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.
|
|
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.
|
|
70
|
+
rails-html-sanitizer (1.6.2)
|
|
71
71
|
loofah (~> 2.21)
|
|
72
|
-
nokogiri (
|
|
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.
|
|
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.
|
|
12
|
-
actionview (= 7.1.
|
|
13
|
-
activesupport (= 7.1.
|
|
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.
|
|
22
|
-
activesupport (= 7.1.
|
|
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.
|
|
28
|
-
activesupport (= 7.1.
|
|
29
|
-
activesupport (7.1.
|
|
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
|
-
|
|
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.
|
|
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.
|
|
73
|
+
mocha (2.7.1)
|
|
69
74
|
ruby2_keywords (>= 0.0.5)
|
|
70
|
-
mutex_m (0.
|
|
71
|
-
nokogiri (1.
|
|
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.
|
|
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.
|
|
88
|
+
rails-html-sanitizer (1.6.2)
|
|
84
89
|
loofah (~> 2.21)
|
|
85
|
-
nokogiri (
|
|
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.
|
|
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.
|
|
58
|
-
loofah (2.
|
|
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.
|
|
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.
|
|
73
|
+
mocha (2.7.1)
|
|
72
74
|
ruby2_keywords (>= 0.0.5)
|
|
73
|
-
nokogiri (1.
|
|
75
|
+
nokogiri (1.17.2-arm64-darwin)
|
|
74
76
|
racc (~> 1.4)
|
|
75
77
|
racc (1.8.1)
|
|
76
|
-
rack (3.1.
|
|
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.
|
|
87
|
+
rails-html-sanitizer (1.6.2)
|
|
86
88
|
loofah (~> 2.21)
|
|
87
|
-
nokogiri (
|
|
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.
|
|
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.
|
|
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
|
|
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
|
|
@@ -4,6 +4,7 @@ require 'date'
|
|
|
4
4
|
require 'time'
|
|
5
5
|
require 'bigdecimal'
|
|
6
6
|
require 'securerandom'
|
|
7
|
+
require 'active_support/json'
|
|
7
8
|
require 'active_support/core_ext/date_time/acts_like'
|
|
8
9
|
require 'active_support/core_ext/date_time/calculations'
|
|
9
10
|
require 'active_support/core_ext/object/acts_like'
|
|
@@ -111,7 +112,7 @@ end
|
|
|
111
112
|
t ||= value if value.is_a?(::Time)
|
|
112
113
|
t ||= value if value.try(:acts_like?, :time)
|
|
113
114
|
t ||= ::Time.parse(String(value))
|
|
114
|
-
t.utc.iso8601
|
|
115
|
+
t.utc.iso8601(::ActiveSupport::JSON::Encoding.time_precision)
|
|
115
116
|
end
|
|
116
117
|
|
|
117
118
|
::Subroutine::TypeCaster.register :date do |value, _options = {}|
|
|
@@ -123,21 +124,16 @@ end
|
|
|
123
124
|
::Subroutine::TypeCaster.register :time, :timestamp, :datetime do |value, options = {}|
|
|
124
125
|
next nil unless value.present?
|
|
125
126
|
|
|
126
|
-
if
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
::Time.parse(String(value))
|
|
131
|
-
end
|
|
132
|
-
else # precision == :seconds
|
|
133
|
-
time = if value.try(:acts_like?, :time)
|
|
134
|
-
value.to_time
|
|
135
|
-
else
|
|
136
|
-
::Time.parse(String(value))
|
|
137
|
-
end
|
|
138
|
-
|
|
139
|
-
time.change(usec: 0)
|
|
127
|
+
value = if value.try(:acts_like?, :time)
|
|
128
|
+
value.to_time
|
|
129
|
+
else
|
|
130
|
+
::Time.parse(String(value))
|
|
140
131
|
end
|
|
132
|
+
|
|
133
|
+
# High precision must be opted into. The original implementation is to set usec:0
|
|
134
|
+
next value if options[:precision] == :high || ::Subroutine.preserve_time_precision?
|
|
135
|
+
|
|
136
|
+
value.change(usec: 0)
|
|
141
137
|
end
|
|
142
138
|
|
|
143
139
|
::Subroutine::TypeCaster.register :hash, :object, :hashmap, :dict do |value, _options = {}|
|
data/lib/subroutine/version.rb
CHANGED
data/lib/subroutine.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "active_model"
|
|
4
|
+
require "active_support"
|
|
4
5
|
require "active_support/concern"
|
|
5
6
|
require "active_support/core_ext/hash/indifferent_access"
|
|
6
7
|
require "active_support/core_ext/module/redefine_method"
|
|
@@ -15,6 +16,18 @@ require "subroutine/op"
|
|
|
15
16
|
|
|
16
17
|
module Subroutine
|
|
17
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
|
+
|
|
18
31
|
def self.include_defaults_in_params=(bool)
|
|
19
32
|
@include_defaults_in_params = !!bool
|
|
20
33
|
end
|
|
@@ -33,4 +46,14 @@ module Subroutine
|
|
|
33
46
|
@inheritable_field_options ||= %i[mass_assignable field_reader field_writer groups aka]
|
|
34
47
|
end
|
|
35
48
|
|
|
49
|
+
def self.preserve_time_precision=(bool)
|
|
50
|
+
@preserve_time_precision = !!bool
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def self.preserve_time_precision?
|
|
54
|
+
return !!@preserve_time_precision if defined?(@preserve_time_precision)
|
|
55
|
+
|
|
56
|
+
false
|
|
57
|
+
end
|
|
58
|
+
|
|
36
59
|
end
|
|
@@ -344,6 +344,20 @@ module Subroutine
|
|
|
344
344
|
assert_equal 0, op.time_input.usec
|
|
345
345
|
end
|
|
346
346
|
|
|
347
|
+
def test_time_inputs__with_preserve_time_precision
|
|
348
|
+
Subroutine.stubs(:preserve_time_precision?).returns(true)
|
|
349
|
+
|
|
350
|
+
time = Time.at(1678741605.123456).utc
|
|
351
|
+
op.time_input = time
|
|
352
|
+
assert_equal 2023, op.time_input.year
|
|
353
|
+
assert_equal 3, op.time_input.month
|
|
354
|
+
assert_equal 13, op.time_input.day
|
|
355
|
+
assert_equal 21, op.time_input.hour
|
|
356
|
+
assert_equal 6, op.time_input.min
|
|
357
|
+
assert_equal 45, op.time_input.sec
|
|
358
|
+
assert_equal 123456, op.time_input.usec
|
|
359
|
+
end
|
|
360
|
+
|
|
347
361
|
def test_time_inputs__with_high_precision
|
|
348
362
|
op.precise_time_input = nil
|
|
349
363
|
assert_nil op.precise_time_input
|
|
@@ -438,11 +452,11 @@ module Subroutine
|
|
|
438
452
|
|
|
439
453
|
op.iso_time_input = '2022-12-22T10:30:24Z'
|
|
440
454
|
assert_equal ::String, op.iso_time_input.class
|
|
441
|
-
assert_equal '2022-12-22T10:30:
|
|
455
|
+
assert_equal '2022-12-22T10:30:24.000Z', op.iso_time_input
|
|
442
456
|
|
|
443
|
-
op.iso_time_input = Time.parse('2022-12-22T10:30:
|
|
457
|
+
op.iso_time_input = Time.parse('2022-12-22T10:30:24.123456Z')
|
|
444
458
|
assert_equal ::String, op.iso_time_input.class
|
|
445
|
-
assert_equal '2022-12-22T10:30:
|
|
459
|
+
assert_equal '2022-12-22T10:30:24.123Z', op.iso_time_input
|
|
446
460
|
end
|
|
447
461
|
|
|
448
462
|
def test_file_inputs
|
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.
|
|
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
|
+
date: 2024-12-19 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activemodel
|
|
@@ -212,7 +212,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
212
212
|
- !ruby/object:Gem::Version
|
|
213
213
|
version: '0'
|
|
214
214
|
requirements: []
|
|
215
|
-
rubygems_version: 3.
|
|
215
|
+
rubygems_version: 3.5.23
|
|
216
216
|
signing_key:
|
|
217
217
|
specification_version: 4
|
|
218
218
|
summary: Feature-driven operation objects.
|