servactory 1.6.8 → 1.6.9

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: 66de0357d02ad9ef590de1d516d1e6d0ea2f9d19d52479cb93e4e4922d6967e5
4
- data.tar.gz: 83f630ec6486102357ef9d4b629dbc4e4f618e55325d97592b16b7530722299f
3
+ metadata.gz: 2c500354cf4e4fdb64d43928419b2d5d90eb99a7f4075bb7b92c78fa0f498748
4
+ data.tar.gz: ffd1d27087d1f5ad5457738c20cda5cb9fa73821fca05cc9cf3161c0c035fb71
5
5
  SHA512:
6
- metadata.gz: 292293afa0bfc8fba8d35605cfc80b6daa75865b3c1ad9d2d1807338c5e784bab0aa94d852b2be54d9157ca8ae44e0c0b2cf9141e92b26256d11d2c08d6ad1e2
7
- data.tar.gz: 93ca03e6db127e20eb04a244e1c48c8596cf910328ab9148543c68da8068ba0cc12be24ed366996e1d72896c88ea474a9fa61f16e2c5d1c87bbbe6ccabc95fa6
6
+ metadata.gz: '039459dc8df65093417fe4b6703783e43ace1c401f86b9b067d5ce3aeeebd0f64866561904a15ea299c2be15224fb66a1fe71dfc8477d7e0f12458f086c09b8a'
7
+ data.tar.gz: 794a191acdc4f2d94d8b827d05c1994a4e644a2124ac2e8fc83106abcfdeb80b35fc069a413c89cf98fc43b22b5f343bb96070d38ed05ffd3f7123d741fc3256
@@ -63,6 +63,7 @@ module Servactory
63
63
  add_must_option_with(options)
64
64
 
65
65
  # Check Class: nil
66
+ add_prepare_option_with(options)
66
67
  add_internal_option_with(options)
67
68
  end
68
69
 
@@ -180,6 +181,29 @@ module Servactory
180
181
  )
181
182
  end
182
183
 
184
+ def add_prepare_option_with(options)
185
+ collection_of_options << Option.new(
186
+ name: :prepare,
187
+ input: self,
188
+ validation_class: nil,
189
+ define_input_methods: [
190
+ DefineInputMethod.new(
191
+ name: :prepare_present?,
192
+ content: ->(value:) { value[:in].present? }
193
+ )
194
+ ],
195
+ define_input_conflicts: [
196
+ DefineInputConflict.new(content: -> { :prepare_vs_array if prepare_present? && array? }),
197
+ DefineInputConflict.new(content: -> { :prepare_vs_inclusion if prepare_present? && inclusion_present? }),
198
+ DefineInputConflict.new(content: -> { :prepare_vs_must if prepare_present? && must_present? })
199
+ ],
200
+ need_for_checks: false,
201
+ value_key: :in,
202
+ value_fallback: false,
203
+ **options
204
+ )
205
+ end
206
+
183
207
  def add_internal_option_with(options) # rubocop:disable Metrics/MethodLength
184
208
  collection_of_options << Option.new(
185
209
  name: :internal,
@@ -31,6 +31,9 @@ module Servactory
31
31
  input_value = @incoming_arguments.fetch(input.name, nil)
32
32
  input_value = input.default if input.optional? && input_value.blank?
33
33
 
34
+ input_prepare = input.prepare.fetch(:in, nil)
35
+ input_value = input_prepare.call(value: input_value) if input_prepare.present?
36
+
34
37
  if input.internal?
35
38
  @internal_variables[input.name] = input_value
36
39
  else
@@ -4,7 +4,7 @@ module Servactory
4
4
  module VERSION
5
5
  MAJOR = 1
6
6
  MINOR = 6
7
- PATCH = 8
7
+ PATCH = 9
8
8
 
9
9
  STRING = [MAJOR, MINOR, PATCH].join(".")
10
10
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: servactory
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.8
4
+ version: 1.6.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Sokolov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-10 00:00:00.000000000 Z
11
+ date: 2023-06-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport