servactory 2.13.1 → 2.13.2

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: b763a59ba9addc399da0f21f95c1b48587a49754f2f67ec4c3cff52e3808840d
4
- data.tar.gz: 7411b3254bbf61e2754c58432540260077c62f58912d881c716d1fb33d3757f2
3
+ metadata.gz: 8d303c7927860fbde7534d718fd64104cce4caad49304636767ef6b0da8f9d3a
4
+ data.tar.gz: d8065166611e2da7a40e6529df84e12002e72e8533cd2015bf5ee867f65f3ca8
5
5
  SHA512:
6
- metadata.gz: df8c6ee28efbe777a6a98bdc4bc1641fdc787a16105f9444418ddad6371e7b913ac3a0dc799c1eefb15d99c97e7b06637db4bb77f5432f3629f5a933524229bf
7
- data.tar.gz: 58e1676c904cff6ac988fdd2616cb9c44768bde908a6364cc7d86fcbdbac417e4fefb664da6a47e6cdb9bd251c5fa0210b22111e3ae4179fb4810097c2bfc5f5
6
+ metadata.gz: f28e93b9cb1932770e44ce8e17d726edef59be66608dd9d68a063d3389db4e71f2cbda685cdbc5081164aa3cb1ff0d6719431078238d0f5053d8f7df97d16e2c
7
+ data.tar.gz: f454f6d653fe7f31e039c5f5b5816863edb7399f433beb4b78f5dc31895d7d86200e0bac374528a85e8855bd0370bb53515c643a55e9ce412571dd2222ce11fe
@@ -47,10 +47,7 @@ module Servactory
47
47
 
48
48
  input_value = @context.send(:servactory_service_warehouse).fetch_input(input.name)
49
49
 
50
- if input.optional? && (
51
- (!input_value.is_a?(TrueClass) && !input_value.is_a?(FalseClass) && input_value.blank?) ||
52
- input_value.nil?
53
- ) # do
50
+ if input.optional? && !input.default.nil? && !Servactory::Utils.value_present?(input_value)
54
51
  input_value = input.default
55
52
  end
56
53
 
@@ -127,18 +127,28 @@ module Servactory
127
127
 
128
128
  ########################################################################
129
129
 
130
- def prepare_object_with!(object:, schema:) # rubocop:disable Metrics/MethodLength
130
+ def prepare_object_with!(object:, schema:) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
131
131
  schema.map do |schema_key, schema_value|
132
132
  attribute_type = schema_value.fetch(:type, String)
133
+ required = schema_value.fetch(:required, true)
134
+ object_value = object[schema_key]
133
135
 
134
136
  if attribute_type == Hash
137
+ default_value = schema_value.fetch(:default, {})
138
+
139
+ if !required && !default_value.nil? && !Servactory::Utils.value_present?(object_value)
140
+ object[schema_key] = default_value
141
+ end
142
+
135
143
  prepare_object_with!(
136
144
  object: object.fetch(schema_key, {}),
137
145
  schema: schema_value.except(*RESERVED_OPTIONS)
138
146
  )
139
147
  else
140
- unless (default = schema_value.fetch(:default, nil)).nil?
141
- object[schema_key] = default
148
+ default_value = schema_value.fetch(:default, nil)
149
+
150
+ if !required && !default_value.nil? && !Servactory::Utils.value_present?(object_value)
151
+ object[schema_key] = default_value
142
152
  end
143
153
 
144
154
  unless (input_prepare = schema_value.fetch(:prepare, nil)).nil?
@@ -4,7 +4,7 @@ module Servactory
4
4
  module VERSION
5
5
  MAJOR = 2
6
6
  MINOR = 13
7
- PATCH = 1
7
+ PATCH = 2
8
8
  PRE = nil
9
9
 
10
10
  STRING = [MAJOR, MINOR, PATCH, PRE].compact.join(".")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: servactory
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.13.1
4
+ version: 2.13.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Sokolov