light-services 0.2.0 → 0.3.0
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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6dc81950e4f4b54c022aaf5541706b2571f65f5a
|
4
|
+
data.tar.gz: 114558b414ac617bf67aeb62ab24ed5e846b89b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8447dc3a9f85f4fdf24d1ab6bc7f789a9caab8ffd81d9883de94e5f8c16b198a9b55a7837408383cb7b3610c409bf0067ffe5e0e4da33bcd8d5db40fff0d4a28
|
7
|
+
data.tar.gz: 7ef1779434b7836916605df9d05c09f613f79cf6d1cfd11d1ee2975a47ee64a8ec830be67ea09f1020130206ccdd413cccd6148019ad5118e988465fdad282b6
|
@@ -28,6 +28,7 @@ module Light
|
|
28
28
|
# Skip or raise exception if parameter not exist
|
29
29
|
unless args.key?(options[:name])
|
30
30
|
next unless options[:required]
|
31
|
+
next if options[:allow_nil]
|
31
32
|
raise Light::Services::ParamRequired, "Parameter \"#{options[:name]}\" is required"
|
32
33
|
end
|
33
34
|
|
@@ -35,7 +36,10 @@ module Light
|
|
35
36
|
value = args[options[:name]]
|
36
37
|
|
37
38
|
# Check type of parameter
|
38
|
-
|
39
|
+
wrong_type = options[:type] && !options[:type].include?(value.class)
|
40
|
+
not_allow_nil = !options[:allow_nil] || (options[:allow_nil] && !value.nil?)
|
41
|
+
|
42
|
+
if wrong_type && not_allow_nil
|
39
43
|
raise Light::Services::ParamType, "Type of \"#{options[:name]}\" must be \"#{options[:type]}\""
|
40
44
|
end
|
41
45
|
|
@@ -76,10 +80,11 @@ module Light
|
|
76
80
|
def param(name, options = {})
|
77
81
|
self.parameters ||= []
|
78
82
|
self.parameters << {
|
79
|
-
name:
|
80
|
-
required:
|
81
|
-
public:
|
82
|
-
type:
|
83
|
+
name: name,
|
84
|
+
required: options.fetch(:required, true),
|
85
|
+
public: options.fetch(:private, false),
|
86
|
+
type: [*options[:type]].compact,
|
87
|
+
allow_nil: options.fetch(:allow_nil, false)
|
83
88
|
}
|
84
89
|
end
|
85
90
|
|