nested 0.0.10 → 0.0.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 +4 -4
- data/lib/nested.rb +6 -6
- data/nested.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 88c760cae3d893d1e9b034623570ca03e5721a53
|
4
|
+
data.tar.gz: af9580cf0059dad6b2bfe775bcce4c7d1c154d4c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e7ba73dcbfca6da1d968d1ae145f175a1b1eb7e535469309c8f4119109cd8b567ae58cc98255f797e8c5e1163d6a184df4f6f23519a39e3388faed9345be279
|
7
|
+
data.tar.gz: 76fe7ba8afd091f19e30b37c146b6669583458a81e6a3c04e3aa9a69415b14f08840e718aac5a275ec9a8d8a596ff98e09448984040f02478352794f7424e699
|
data/lib/nested.rb
CHANGED
@@ -201,9 +201,9 @@ module Nested
|
|
201
201
|
(response.is_a?(ActiveModel::Errors) || (response.respond_to?(:errors) && !response.errors.empty?)) ? :error : :data
|
202
202
|
end
|
203
203
|
|
204
|
-
def sinatra_response(sinatra)
|
204
|
+
def sinatra_response(sinatra, method)
|
205
205
|
response = sinatra.instance_variable_get("@#{self.instance_variable_name}")
|
206
|
-
response = self.send(:"sinatra_response_create_#{sinatra_response_type(response)}", sinatra, response)
|
206
|
+
response = self.send(:"sinatra_response_create_#{sinatra_response_type(response)}", sinatra, response, method)
|
207
207
|
|
208
208
|
case response
|
209
209
|
when String then response
|
@@ -211,8 +211,8 @@ module Nested
|
|
211
211
|
end
|
212
212
|
end
|
213
213
|
|
214
|
-
def sinatra_response_create_data(sinatra, response)
|
215
|
-
data = if response && collection?
|
214
|
+
def sinatra_response_create_data(sinatra, response, method)
|
215
|
+
data = if response && collection? && method != :post
|
216
216
|
response.to_a.map{|e| sinatra.instance_exec(e, &@__serialize) }
|
217
217
|
else
|
218
218
|
sinatra.instance_exec(response, &@__serialize)
|
@@ -221,7 +221,7 @@ module Nested
|
|
221
221
|
{data: data, ok: true}
|
222
222
|
end
|
223
223
|
|
224
|
-
def sinatra_response_create_error(sinatra, response)
|
224
|
+
def sinatra_response_create_error(sinatra, response, method)
|
225
225
|
errors = response.is_a?(ActiveModel::Errors) ? response : response.errors
|
226
226
|
|
227
227
|
data = errors.to_hash.inject({}) do |memo, e|
|
@@ -249,7 +249,7 @@ module Nested
|
|
249
249
|
|
250
250
|
resource.send(:"sinatra_exec_#{method}_block", self, &block)
|
251
251
|
|
252
|
-
resource.sinatra_response(self)
|
252
|
+
resource.sinatra_response(self, method)
|
253
253
|
end
|
254
254
|
end
|
255
255
|
end
|
data/nested.gemspec
CHANGED