lightspeed_restaurant 0.1.5 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b455bf08e0c2af217e66cec7d63bfe22e4a93eaa
4
- data.tar.gz: 4c7a6b0dcba4b2c24936108b1ebe48ea82a4e670
3
+ metadata.gz: 56e75042c46fc74a5583e60722906e07bc755f82
4
+ data.tar.gz: 67491992739dc6b5004472eea7073a2e3e09b159
5
5
  SHA512:
6
- metadata.gz: 5675d34001aee365992a75b83ad8b7020ca7b975db3f66bca1fa47aafbda5ee39bce3aa8c3a0448342f7ac221ea6a0059dd42d8bdff342b2e76ccaf192c1396f
7
- data.tar.gz: 1d80cce1918cee6a38a9ddad29516a952f9359267f50cca6c1fa5e2c376c6b19e88de51cda4cfc7bed55db856390c09394475e6868abe1253bb50c6fc606a971
6
+ metadata.gz: 998ec24bb48dcade87256889928a07ab3752f19cf843f2372fe8c869891615a1784215c815787947da3e0ccd1f6e8ec6f9b5fa44705906fcfd36021b326c1c98
7
+ data.tar.gz: 4225df362838635e0583e129f9a080dd54415531352e48dea5de0be46d171fc5f909af87527d332238a571ab5f251ead8268acbfd0a3b2dd36da009874f153fc
data/.rubocop.yml CHANGED
@@ -4,6 +4,10 @@ Metrics/LineLength:
4
4
  Metrics/MethodLength:
5
5
  Max: 20
6
6
 
7
+ Metrics/BlockLength:
8
+ Exclude:
9
+ - 'spec/**/*'
10
+
7
11
  Style/Documentation:
8
12
  Exclude:
9
13
  - 'spec/**/*'
@@ -3,11 +3,19 @@ module LightspeedRestaurant
3
3
  module Create
4
4
  def create(attributes)
5
5
  response = LightspeedRestaurant.post(resource_path, attributes)
6
- if is_a?(Class)
7
- new(attributes.merge!(id: response.to_i))
8
- else
9
- self.class.new(attributes.merge!(id: response.to_i))
10
- end
6
+ payload = build_payload(attributes, response)
7
+ return new(payload) if is_a?(Class)
8
+
9
+ self.class.new(payload)
10
+ end
11
+
12
+ private
13
+
14
+ def build_payload(attributes, response)
15
+ JSON.parse(response)
16
+ rescue JSON::ParserError => error
17
+ raise error if response.to_i.zero?
18
+ attributes.merge!(id: response.to_i)
11
19
  end
12
20
  end
13
21
  end
@@ -1,3 +1,3 @@
1
1
  module LightspeedRestaurant
2
- VERSION = '0.1.5'.freeze
2
+ VERSION = '0.2.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lightspeed_restaurant
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Olivier Buffon
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-04-05 00:00:00.000000000 Z
11
+ date: 2017-03-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: excon