smart_init 3.1.0 → 3.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -0
- data/lib/smart_init/main.rb +4 -0
- data/lib/smart_init/version.rb +1 -1
- data/test/test_api.rb +6 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34a07f2fa3876c9ca80bb60bf76e045aa0c96f408abb6f761c8b80a5d988806a
|
4
|
+
data.tar.gz: ca8b35191d340a1a43138e7698c8c0bd6f8f1d3d90787d252bf67d66e33e1f22
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10780f72f2f6e43497fe4fbde549cfdd4cedf7db3c704bad8cc44f0c21f296d34e374bda479cd81835df1a44bac06708500ab4dcaa47ac3ec469ecc6341e66ce
|
7
|
+
data.tar.gz: 00c1fb99e8891cf6fb4081c42d03ff00b2f6e511350c630529d7255735b353156e9f50cdef5a9e6c2c3018e0032430685a317afbd0d3a33a5b11be0ee643509e
|
data/README.md
CHANGED
@@ -50,7 +50,13 @@ object = ApiClient.new(network_provider: Faraday.new, api_token: 'secret_token')
|
|
50
50
|
# <ApiClient:0x007fa16684ec20 @network_provider=Faraday<...>, @api_token="secret_token">
|
51
51
|
```
|
52
52
|
|
53
|
+
If you omit a required attribute an `ArgumentError` will be thrown:
|
53
54
|
|
55
|
+
```ruby
|
56
|
+
object = ApiClient.new(network_provider: Faraday.new)
|
57
|
+
|
58
|
+
# ArgumentError (missing required attribute api_token)
|
59
|
+
```
|
54
60
|
|
55
61
|
You can also use `is_callable` method:
|
56
62
|
|
data/lib/smart_init/main.rb
CHANGED
@@ -10,6 +10,10 @@ module SmartInit
|
|
10
10
|
default_value_attrs = attributes.select { |attr| attr.is_a?(Hash) }.first || {}
|
11
11
|
|
12
12
|
define_method :initialize do |*parameters|
|
13
|
+
unless parameters.first.is_a?(Hash)
|
14
|
+
raise ArgumentError, "invalid input, expected hash of attributes"
|
15
|
+
end
|
16
|
+
|
13
17
|
required_attrs.each do |required_attr|
|
14
18
|
unless parameters.first.has_key?(required_attr)
|
15
19
|
raise ArgumentError, "missing required attribute #{required_attr}"
|
data/lib/smart_init/version.rb
CHANGED
data/test/test_api.rb
CHANGED