easy_api 0.1.1 → 0.1.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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/easy_api/object.rb +10 -5
- data/lib/easy_api.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da65ca4da22f0eb00d5a0f415b430d466daf0f23
|
4
|
+
data.tar.gz: 3e170ac28fe723c30ef34e4667348b3f92b27c38
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 467ac9f0bd656e485e3d0857210d00237006a5b359c716e4cb0208ee47d14dda94b3c7bbfd920432b2c651740ad4131816174a64b54537b1cb54de2a9e4c7c34
|
7
|
+
data.tar.gz: 679aaed06073c49e81d59808ba307bc2c2fae6871fa70b5f401a6e6ee473949254163d09d31ab5454e07f7dd228b089c6c1d8538a2ab4427515c11f88ede4a3a
|
data/Gemfile.lock
CHANGED
data/lib/easy_api/object.rb
CHANGED
@@ -12,20 +12,25 @@ module EasyApi
|
|
12
12
|
def_delegators(:attributes, :size, :[], :each)
|
13
13
|
|
14
14
|
def initialize(data)
|
15
|
-
raise EasyApi::MissingRequiredAttributeError unless required_attribute_names.all?
|
16
|
-
|
15
|
+
raise EasyApi::MissingRequiredAttributeError unless required_attribute_names.all? do |name|
|
16
|
+
data.keys.include?(name) || data.keys.include?(name.to_s)
|
17
|
+
end
|
18
|
+
|
19
|
+
raise EasyApi::UnknownAttributeError if data.keys.any? do |key|
|
20
|
+
!attribute_names.include?(key) && !attribute_names.include?(key.to_sym)
|
21
|
+
end
|
17
22
|
|
18
23
|
@attributes = data.map do |k, v|
|
19
24
|
next [k, v] unless v.instance_of? Hash
|
20
25
|
|
21
26
|
v =
|
22
|
-
if object_class = schema[k]
|
27
|
+
if object_class = schema[k.to_sym]
|
23
28
|
object_class.new(v)
|
24
29
|
else
|
25
|
-
OpenStruct.new(v)
|
30
|
+
OpenStruct.new(v)
|
26
31
|
end
|
27
32
|
|
28
|
-
[k, v]
|
33
|
+
[k.to_sym, v]
|
29
34
|
end.to_h
|
30
35
|
end
|
31
36
|
|
data/lib/easy_api.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: easy_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephan Meijer
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-05-
|
11
|
+
date: 2018-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|