dried_interaction 0.3.0 → 0.3.1

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: fc03f8cdd296c8e6d4e02569d36c852230788f2e3fcdbfea27190e9dc7b4ceac
4
- data.tar.gz: 43c97474d74f55612a51bb37b30e6a378b80d1a983d90662efb9fd74f04a67ab
3
+ metadata.gz: 160ab6be7540d1ed3d7672df8ee5f1362d540462f6cc72b69f515bed212ac7fb
4
+ data.tar.gz: b9429267e0d60062795fd89e87f980817ab159728b6c0e01e3654acde7b180f7
5
5
  SHA512:
6
- metadata.gz: 174a2ad3439cb18b6e9e929ac2b838daa914d12dbb42c98360bf31bc5b66d79bba0e3fd01d883b73833e8c5ab43a6d431ea59ddf67155ca162ff15489409c76c
7
- data.tar.gz: 24548abcd09e1b2ee14ca632eb559815fbdb4477982ac2ee890d7c72430bb7155e6cb038bc803976108e2c313a44e07778a29d622f812840a1ab5abd79b162ec
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, :for_method
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
- def soft_contract(args = {}, &block)
18
- contract(args.merge(mode: :soft), &block)
19
- end
20
-
21
- def strict_contract(args = {}, &block)
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)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DriedInteraction
4
- VERSION = '0.3.0'
4
+ VERSION = '0.3.1'
5
5
  end
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.0
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 00:00:00.000000000 Z
11
+ date: 2023-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-initializer