subroutine 2.1.0 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/subroutine/fields.rb +2 -2
- data/lib/subroutine/version.rb +1 -1
- data/test/subroutine/fields_test.rb +7 -0
- data/test/support/ops.rb +23 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 359d2ea93dea5768e77277086229a0dd6e38c90c6f05866e443980a45afd98f9
|
4
|
+
data.tar.gz: a1282dec003600a234fd8e8a076570f91813681d4eb3afdd84c4193ad8b115bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e01d4ab80fce0047950af6511d5b626e740f1a7e1157e283f09a911dbeaab21af01ae5b173c750e7078f57c28f058000e428df4eca784e522496cc8053fb2617
|
7
|
+
data.tar.gz: 423ddf621546c4d74c1934f476aab6e0da728379490ac7b6d8f0b420b8dde3d101e8a1f0cdb8369908d87dd34fd21ef119627e10c78acd7d88aac8064b65216b
|
data/lib/subroutine/fields.rb
CHANGED
@@ -216,9 +216,9 @@ module Subroutine
|
|
216
216
|
field_provided?(name) ? all_params[name] : all_default_params[name]
|
217
217
|
end
|
218
218
|
|
219
|
-
def set_field(name, value,
|
219
|
+
def set_field(name, value, opts = {})
|
220
220
|
config = get_field_config(name)
|
221
|
-
@provided_fields[name] = true
|
221
|
+
@provided_fields[name] = true unless opts[:track_provided] == false
|
222
222
|
value = attempt_cast(value, config) do |e|
|
223
223
|
"Error during assignment of field `#{name}`: #{e}"
|
224
224
|
end
|
data/lib/subroutine/version.rb
CHANGED
@@ -136,5 +136,12 @@ module Subroutine
|
|
136
136
|
assert_equal({}.with_indifferent_access, op.without_inherited_params)
|
137
137
|
end
|
138
138
|
|
139
|
+
def test_fields_are_inherited_to_subclasses
|
140
|
+
assert_equal(%i[amount_cents], ParentInheritanceOp.field_configurations.keys.sort)
|
141
|
+
assert_equal(%i[debit_cents], ParentInheritanceOp::EarlyInheritanceOp.field_configurations.keys.sort)
|
142
|
+
assert_equal(%i[amount_cents debit_cents], ParentInheritanceOp::LateInheritanceOp.field_configurations.keys.sort)
|
143
|
+
assert_equal(%i[amount_cents credit_cents], OuterInheritanceOp.field_configurations.keys.sort)
|
144
|
+
end
|
145
|
+
|
139
146
|
end
|
140
147
|
end
|
data/test/support/ops.rb
CHANGED
@@ -284,10 +284,33 @@ class UnlessConditionalPolicyOp < OpWithAuth
|
|
284
284
|
|
285
285
|
end
|
286
286
|
|
287
|
+
class ParentInheritanceOp < ::Subroutine::Op
|
288
|
+
class EarlyInheritanceOp < ParentInheritanceOp
|
289
|
+
integer :debit_cents
|
290
|
+
end
|
291
|
+
|
292
|
+
integer :amount_cents
|
293
|
+
|
294
|
+
class LateInheritanceOp < ParentInheritanceOp
|
295
|
+
integer :debit_cents
|
296
|
+
end
|
297
|
+
|
298
|
+
end
|
299
|
+
|
300
|
+
class OuterInheritanceOp < ParentInheritanceOp
|
301
|
+
|
302
|
+
integer :credit_cents
|
303
|
+
|
304
|
+
end
|
305
|
+
|
287
306
|
class OpWithAssociation < ::Subroutine::Op
|
288
307
|
|
289
308
|
include ::Subroutine::AssociationFields
|
290
309
|
|
310
|
+
def perform
|
311
|
+
false
|
312
|
+
end
|
313
|
+
|
291
314
|
end
|
292
315
|
|
293
316
|
class SimpleAssociationOp < ::OpWithAssociation
|
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: 2.1.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Nelson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|