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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d303c7927860fbde7534d718fd64104cce4caad49304636767ef6b0da8f9d3a
|
4
|
+
data.tar.gz: d8065166611e2da7a40e6529df84e12002e72e8533cd2015bf5ee867f65f3ca8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
141
|
-
|
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?
|
data/lib/servactory/version.rb
CHANGED