subroutine 2.3.1 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/CODEOWNERS +1 -0
- data/.github/dependabot.yml +24 -0
- data/.github/workflows/build.yml +2 -2
- data/.ruby-version +1 -1
- data/CHANGELOG.MD +4 -0
- data/Gemfile +1 -1
- data/gemfiles/am61.gemfile +4 -0
- data/lib/subroutine/op.rb +5 -4
- data/lib/subroutine/type_caster.rb +5 -3
- data/lib/subroutine/version.rb +3 -3
- data/subroutine.gemspec +3 -3
- data/test/subroutine/association_test.rb +17 -0
- metadata +13 -21
- data/gemfiles/am41.gemfile +0 -7
- data/gemfiles/am42.gemfile +0 -7
- data/gemfiles/am50.gemfile +0 -6
- data/gemfiles/am51.gemfile +0 -6
- data/gemfiles/am52.gemfile +0 -6
- data/gemfiles/am60.gemfile +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d089cc45475bdb88ee182f34ef6cbfc2fcb4c77d039fce887fd3bd420a2f210
|
4
|
+
data.tar.gz: 454b7650e82cccfe16af31d8bb7ca5739763cacdcd1cab4ef810a25634dab480
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43420206b0becfd866a4ec01aa757d20c780bb939ed666c94878c8c73645561672646b230850aa199652776204f50562c0b675b37973d6efcb9ce831fc3b4d9c
|
7
|
+
data.tar.gz: dc313998225594aac7480cbf9df3e5b539589c13ef041adccb39ef97c583f0608d8a5b7b7e55245d58816b98db159a8d4fedd42d39f6b72317add6670a3ac7cc
|
data/.github/CODEOWNERS
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
.github/workflows @guideline-tech/engineering
|
@@ -0,0 +1,24 @@
|
|
1
|
+
version: 2
|
2
|
+
updates:
|
3
|
+
- package-ecosystem: "github-actions"
|
4
|
+
directory: "/"
|
5
|
+
open-pull-requests-limit: 20
|
6
|
+
schedule:
|
7
|
+
interval: "daily"
|
8
|
+
time: "09:00"
|
9
|
+
timezone: "America/New_York"
|
10
|
+
commit-message:
|
11
|
+
prefix: "[github-actions] "
|
12
|
+
- package-ecosystem: "bundler"
|
13
|
+
directory: "/"
|
14
|
+
schedule:
|
15
|
+
interval: "daily"
|
16
|
+
time: "08:30"
|
17
|
+
timezone: "America/New_York"
|
18
|
+
versioning-strategy: increase
|
19
|
+
open-pull-requests-limit: 20
|
20
|
+
insecure-external-code-execution: deny
|
21
|
+
allow:
|
22
|
+
- dependency-type: "all"
|
23
|
+
commit-message:
|
24
|
+
prefix: "[bundler] "
|
data/.github/workflows/build.yml
CHANGED
@@ -7,7 +7,7 @@ jobs:
|
|
7
7
|
strategy:
|
8
8
|
fail-fast: false
|
9
9
|
matrix:
|
10
|
-
ruby-version: [2.7.
|
10
|
+
ruby-version: [2.7.8]
|
11
11
|
experimental: [false]
|
12
12
|
include:
|
13
13
|
- ruby-version: 3.0
|
@@ -15,7 +15,7 @@ jobs:
|
|
15
15
|
- ruby-version: 3.1
|
16
16
|
experimental: true
|
17
17
|
steps:
|
18
|
-
- uses: actions/checkout@
|
18
|
+
- uses: actions/checkout@v3
|
19
19
|
- uses: ruby/setup-ruby@v1
|
20
20
|
with:
|
21
21
|
ruby-version: ${{ matrix.ruby-version }}
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.7.
|
1
|
+
2.7.8
|
data/CHANGELOG.MD
CHANGED
data/Gemfile
CHANGED
data/lib/subroutine/op.rb
CHANGED
@@ -112,9 +112,10 @@ module Subroutine
|
|
112
112
|
end
|
113
113
|
|
114
114
|
def inherit_errors(error_object, prefix: nil)
|
115
|
-
error_object = error_object.errors if error_object.respond_to?(:errors)
|
115
|
+
error_object = error_object.errors if error_object.respond_to?(:errors) && !error_object.is_a?(ActiveModel::Errors)
|
116
116
|
|
117
|
-
error_object.each do |
|
117
|
+
error_object.each do |error|
|
118
|
+
field_name = error.attribute
|
118
119
|
field_name = "#{prefix}#{field_name}" if prefix
|
119
120
|
field_name = field_name.to_sym
|
120
121
|
|
@@ -125,9 +126,9 @@ module Subroutine
|
|
125
126
|
end
|
126
127
|
|
127
128
|
if field_config
|
128
|
-
errors.add(field_config.field_name, error)
|
129
|
+
errors.add(field_config.field_name, error.message)
|
129
130
|
else
|
130
|
-
errors.add(:base, error_object.full_message(field_name, error))
|
131
|
+
errors.add(:base, error_object.full_message(field_name, error.message))
|
131
132
|
end
|
132
133
|
end
|
133
134
|
|
@@ -65,9 +65,11 @@ end
|
|
65
65
|
|
66
66
|
::Subroutine::TypeCaster.register :foreign_key do |value, options = {}|
|
67
67
|
next nil if value.blank?
|
68
|
-
|
69
|
-
|
70
|
-
|
68
|
+
|
69
|
+
calculated_type = options[:foreign_key_type].respond_to?(:call)
|
70
|
+
calculated_value = calculated_type ? options[:foreign_key_type].call : options[:foreign_key_type]
|
71
|
+
|
72
|
+
next ::Subroutine::TypeCaster.cast(value, type: calculated_value) if calculated_value
|
71
73
|
next ::Subroutine::TypeCaster.cast(value, type: :integer) if options[:name] && options[:name].to_s.end_with?("_id")
|
72
74
|
|
73
75
|
value
|
data/lib/subroutine/version.rb
CHANGED
data/subroutine.gemspec
CHANGED
@@ -19,10 +19,10 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.test_files = spec.files.grep(%r{^(gemfiles|test)/})
|
20
20
|
spec.require_paths = ["lib"]
|
21
21
|
|
22
|
-
spec.add_dependency "activemodel", ">=
|
23
|
-
spec.add_dependency "activesupport", ">=
|
22
|
+
spec.add_dependency "activemodel", ">= 6.1"
|
23
|
+
spec.add_dependency "activesupport", ">= 6.1"
|
24
24
|
|
25
|
-
spec.add_development_dependency "actionpack", ">=
|
25
|
+
spec.add_development_dependency "actionpack", ">= 6.1"
|
26
26
|
spec.add_development_dependency "bundler"
|
27
27
|
spec.add_development_dependency "byebug"
|
28
28
|
spec.add_development_dependency "m"
|
@@ -231,6 +231,11 @@ module Subroutine
|
|
231
231
|
assert_equal true, op.field_provided?(:admin_id)
|
232
232
|
assert_equal true, op.field_provided?(:admin_type)
|
233
233
|
|
234
|
+
op = PolymorphicAssociationOp.new admin_type: doug.class.name, admin_id: doug.id.to_s
|
235
|
+
assert_equal true, op.field_provided?(:admin)
|
236
|
+
assert_equal true, op.field_provided?(:admin_id)
|
237
|
+
assert_equal true, op.field_provided?(:admin_type)
|
238
|
+
|
234
239
|
op = PolymorphicAssociationOp.new admin_id: doug.id
|
235
240
|
assert_equal false, op.field_provided?(:admin)
|
236
241
|
assert_equal true, op.field_provided?(:admin_id)
|
@@ -293,6 +298,18 @@ module Subroutine
|
|
293
298
|
assert_equal({ "admin_id" => 1, "admin_type" => "User" }, op.params)
|
294
299
|
end
|
295
300
|
|
301
|
+
def test_params_id_type_as_integer_for_polymorphic_associations
|
302
|
+
user = ::User.new(id: 1)
|
303
|
+
|
304
|
+
op = PolymorphicAssociationOp.new(admin_id: user.id)
|
305
|
+
op.admin
|
306
|
+
assert_equal({ "admin_id" => 1 }, op.params)
|
307
|
+
|
308
|
+
op = PolymorphicAssociationOp.new(admin_id: user.id.to_s)
|
309
|
+
op.admin
|
310
|
+
assert_equal({ "admin_id" => 1 }, op.params)
|
311
|
+
end
|
312
|
+
|
296
313
|
def test_params_can_be_accessed_with_associations_loaded
|
297
314
|
user = User.new(id: 1)
|
298
315
|
op = SimpleAssociationOp.new(user: user)
|
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
|
+
version: 3.0.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: 2023-
|
11
|
+
date: 2023-06-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -16,42 +16,42 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: '6.1'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: '6.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activesupport
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: '6.1'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: '6.1'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: actionpack
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '6.1'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '6.1'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: bundler
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -157,6 +157,8 @@ executables: []
|
|
157
157
|
extensions: []
|
158
158
|
extra_rdoc_files: []
|
159
159
|
files:
|
160
|
+
- ".github/CODEOWNERS"
|
161
|
+
- ".github/dependabot.yml"
|
160
162
|
- ".github/workflows/build.yml"
|
161
163
|
- ".gitignore"
|
162
164
|
- ".ruby-gemset"
|
@@ -166,12 +168,7 @@ files:
|
|
166
168
|
- LICENSE.txt
|
167
169
|
- README.md
|
168
170
|
- Rakefile
|
169
|
-
- gemfiles/
|
170
|
-
- gemfiles/am42.gemfile
|
171
|
-
- gemfiles/am50.gemfile
|
172
|
-
- gemfiles/am51.gemfile
|
173
|
-
- gemfiles/am52.gemfile
|
174
|
-
- gemfiles/am60.gemfile
|
171
|
+
- gemfiles/am61.gemfile
|
175
172
|
- lib/subroutine.rb
|
176
173
|
- lib/subroutine/association_fields.rb
|
177
174
|
- lib/subroutine/association_fields/association_type_mismatch_error.rb
|
@@ -220,17 +217,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
220
217
|
- !ruby/object:Gem::Version
|
221
218
|
version: '0'
|
222
219
|
requirements: []
|
223
|
-
rubygems_version: 3.
|
220
|
+
rubygems_version: 3.4.10
|
224
221
|
signing_key:
|
225
222
|
specification_version: 4
|
226
223
|
summary: Feature-driven operation objects.
|
227
224
|
test_files:
|
228
|
-
- gemfiles/
|
229
|
-
- gemfiles/am42.gemfile
|
230
|
-
- gemfiles/am50.gemfile
|
231
|
-
- gemfiles/am51.gemfile
|
232
|
-
- gemfiles/am52.gemfile
|
233
|
-
- gemfiles/am60.gemfile
|
225
|
+
- gemfiles/am61.gemfile
|
234
226
|
- test/subroutine/association_test.rb
|
235
227
|
- test/subroutine/auth_test.rb
|
236
228
|
- test/subroutine/base_test.rb
|
data/gemfiles/am41.gemfile
DELETED
data/gemfiles/am42.gemfile
DELETED
data/gemfiles/am50.gemfile
DELETED
data/gemfiles/am51.gemfile
DELETED
data/gemfiles/am52.gemfile
DELETED