dried_interaction 0.3.0 → 0.3.1
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 160ab6be7540d1ed3d7672df8ee5f1362d540462f6cc72b69f515bed212ac7fb
|
4
|
+
data.tar.gz: b9429267e0d60062795fd89e87f980817ab159728b6c0e01e3654acde7b180f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dfbe0f6c739498cdf5a0b1f39b35889c91c9c4b523a8d408a7c3aed715f79e704f4b4a2272bbd9eb3afa09226713bc0808a505d7b7dafcc91a0635c858fc01a9
|
7
|
+
data.tar.gz: f40319e60a0f525229541fa8db558475958e1ee791d40998ed0fce7a5bb0d5e785688e515a70b20e3b4f7b7ba31c05fafb83bab0e91a1cffb2ee43411346e98c
|
@@ -2,24 +2,22 @@
|
|
2
2
|
|
3
3
|
require 'dry/validation'
|
4
4
|
require 'dry/schema'
|
5
|
-
require 'dried_interaction/instance_methods'
|
6
5
|
|
7
6
|
module DriedInteraction
|
8
7
|
module Dsl
|
9
8
|
MODES = %i[strict soft].freeze
|
10
|
-
attr_accessor :contract_validator, :contract_mode
|
9
|
+
attr_accessor :contract_validator, :contract_mode
|
11
10
|
|
12
11
|
def contract(kind: :simple, mode: MODES.first, &block)
|
13
12
|
@contract_mode = resolve_contract_mode(mode)
|
14
13
|
@contract_validator = resolve_contract_validator(kind, &block)
|
15
14
|
end
|
16
15
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
contract(args.merge(mode: :strict))
|
16
|
+
# soft_contract, strict_contract
|
17
|
+
MODES.each do |mode|
|
18
|
+
define_method("#{mode}_contract") do |args = {}, &block|
|
19
|
+
contract(args.merge(mode: mode), &block)
|
20
|
+
end
|
23
21
|
end
|
24
22
|
|
25
23
|
private
|
@@ -8,11 +8,11 @@ module DriedInteraction
|
|
8
8
|
include Dry::Monads[:result]
|
9
9
|
|
10
10
|
def call(*args)
|
11
|
-
interaction_contract_error('Call method allows only one argument') if args.size != 1
|
11
|
+
return interaction_contract_error('Call method allows only one argument') if args.size != 1
|
12
12
|
arg = args.first
|
13
13
|
|
14
14
|
contract = self.class.contract_validator
|
15
|
-
interaction_contract_error('Contract must be filled') if arg && !contract
|
15
|
+
return interaction_contract_error('Contract must be filled') if arg && !contract
|
16
16
|
|
17
17
|
contract_params = fetch_contract_params(contract)
|
18
18
|
check_result = check_params_presence_in_args(contract_params, arg.keys)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dried_interaction
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- gl-pv
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-04-
|
11
|
+
date: 2023-04-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-initializer
|