yodatra 0.3.10 → 0.3.11

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: 581ebcb300386a581d11626427193627caefcced
4
- data.tar.gz: 32373f7bfc1606cc44bca3368e1fa4204058f733
3
+ metadata.gz: fc8c33bcd36806fd5364c47084a00d1794640ce4
4
+ data.tar.gz: c0f166b07bc87e9e39e178cd8a72307e2907a51f
5
5
  SHA512:
6
- metadata.gz: 8501f66cb7f3f40a9c7b325543a4af79cae4e74f1b01ff801f0c5622376bfa333913b2ab03ae61223835d1f5165f1c50f4bb2f0617c8eda87363bdf4f5bf92fd
7
- data.tar.gz: 111d95bb8d5c5ca04eddf54238f72d7d3bd57c217a2bc1b6e42bc954d13a3a0e8c32de49c4777797b80a7ef006cf8b125b58b3b5e0968e0113e6646a3cddd343
6
+ metadata.gz: f4aad69d38313d2832636f1ab9c8e52d544c4b2646c89a148b842ecbe527127b134d7dc5dab1003ec5c8153fb3545e48e32cc1c25ee7bc04dc14db8201384077
7
+ data.tar.gz: c9691823c945849b5360e5b6a3bd7243449647d202dc727829ef011e745bd5fff4731d7d2beea30430375118007dc82fce98cc5fa621670c4f1ed897abd1f5c6
@@ -77,14 +77,18 @@ module Yodatra
77
77
  CREATE_ONE = :create
78
78
  post ALL_ROUTE do
79
79
  retrieve_resources CREATE_ONE do |resource|
80
- hash = self.send("#{model_name.underscore}_params".to_sym)
81
- @one = resource.create hash
82
-
83
- if @one.id.nil?
84
- status 400
85
- @one.errors.full_messages
80
+ if resource.nil?
81
+ not_allowed
86
82
  else
87
- @one.as_json(read_scope)
83
+ hash = self.send("#{model_name.underscore}_params".to_sym)
84
+ @one = resource.create hash
85
+
86
+ if @one.id.nil?
87
+ status 400
88
+ @one.errors.full_messages
89
+ else
90
+ @one.as_json(read_scope)
91
+ end
88
92
  end
89
93
  end
90
94
  end
@@ -272,5 +276,9 @@ module Yodatra
272
276
  ['record not found']
273
277
  end
274
278
 
279
+ def not_allowed
280
+ status 401
281
+ ['not allowed']
282
+ end
275
283
  end
276
284
  end
@@ -1,3 +1,3 @@
1
1
  module Yodatra
2
- VERSION = '0.3.10'
2
+ VERSION = '0.3.11'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yodatra
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.10
4
+ version: 0.3.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Bonaud