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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8796cb69b2fac857b68a1967154915842359f548
4
- data.tar.gz: 15e996fd1e0437352cd053f4aef1f7467f49ab85
3
+ metadata.gz: da65ca4da22f0eb00d5a0f415b430d466daf0f23
4
+ data.tar.gz: 3e170ac28fe723c30ef34e4667348b3f92b27c38
5
5
  SHA512:
6
- metadata.gz: b487103efdc0694eb0f4b3fba7bc07d1fcba2ff6e86bea170c3ae4fe6869049d05b5ff300dbb738c7098c9329642069890747b5f606b66e0bf9e080eb794af33
7
- data.tar.gz: d33705a383103425d4b1d180ca17a63d45a38462d14fc2329420cf12265c163b17ff6270a1f62285cfd2b899af0705e89d7996079ca8c51032ba7864102f7d82
6
+ metadata.gz: 467ac9f0bd656e485e3d0857210d00237006a5b359c716e4cb0208ee47d14dda94b3c7bbfd920432b2c651740ad4131816174a64b54537b1cb54de2a9e4c7c34
7
+ data.tar.gz: 679aaed06073c49e81d59808ba307bc2c2fae6871fa70b5f401a6e6ee473949254163d09d31ab5454e07f7dd228b089c6c1d8538a2ab4427515c11f88ede4a3a
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- easy_api (0.1.0)
4
+ easy_api (0.1.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -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? { |name| data.keys.include? name }
16
- raise EasyApi::UnknownAttributeError if data.keys.any? { |key| !attribute_names.include? key }
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) # TODO: maybe create OpenStructObject which creates OpenStruct instance and parses
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
@@ -1,5 +1,5 @@
1
1
  require "easy_api/object"
2
2
 
3
3
  module EasyApi
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
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.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-08 00:00:00.000000000 Z
11
+ date: 2018-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler