toast 1.0.14 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/toast/canonical_request.rb +6 -3
- data/lib/toast/collection_request.rb +5 -3
- data/lib/toast/errors.rb +3 -1
- data/lib/toast/plural_assoc_request.rb +8 -4
- data/lib/toast/request_helpers.rb +2 -2
- data/lib/toast/single_request.rb +2 -1
- data/lib/toast/singular_assoc_request.rb +6 -3
- data/lib/toast/version.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: 7b13e469679d7d7b0d50207808e3b03a634d8ea3
|
4
|
+
data.tar.gz: d61fdc8ec1c63c7c1b45bedc0d79930d07d5574d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80e314e9b379d2766b966651a0bb62777907823572ffbd6ad15353bcee9de63043ad078f85f320a148394c2e722a9c9b454a127483fe00c9e55e73699388c0ed
|
7
|
+
data.tar.gz: bd67aa8501fc98050bd51b910388659dfa380c696a6abfb980779e673d01a89c85db08042f4be7d4876226c89eb8a2b25b092247acf46789a4a49d1bbcead56c
|
@@ -51,7 +51,8 @@ class Toast::CanonicalRequest
|
|
51
51
|
response :not_found, msg: "#{@base_config.model_class}##{@id} not found"
|
52
52
|
|
53
53
|
rescue BadRequest => error
|
54
|
-
response :bad_request, msg: "`#{error.message}' in: #{error.source_location}"
|
54
|
+
response :bad_request, msg: "`#{error.message}' in: #{error.source_location}",
|
55
|
+
headers: {'X-Toast-Error' => error.code}
|
55
56
|
|
56
57
|
rescue AllowError => error
|
57
58
|
response :internal_server_error,
|
@@ -117,7 +118,8 @@ class Toast::CanonicalRequest
|
|
117
118
|
response :not_found, msg: error.message
|
118
119
|
|
119
120
|
rescue BadRequest => error
|
120
|
-
response :bad_request, msg: "`#{error.message}' in: #{error.source_location}"
|
121
|
+
response :bad_request, msg: "`#{error.message}' in: #{error.source_location}",
|
122
|
+
headers: {'X-Toast-Error' => error.code}
|
121
123
|
|
122
124
|
rescue AllowError => error
|
123
125
|
response :internal_server_error,
|
@@ -165,7 +167,8 @@ class Toast::CanonicalRequest
|
|
165
167
|
msg: "exception raised in allow block: `#{error.orig_error.message}' in #{error.source_location}"
|
166
168
|
|
167
169
|
rescue BadRequest => error
|
168
|
-
response :bad_request, msg: "`#{error.message}' in: #{error.source_location}"
|
170
|
+
response :bad_request, msg: "`#{error.message}' in: #{error.source_location}",
|
171
|
+
headers: {'X-Toast-Error' => error.code}
|
169
172
|
|
170
173
|
rescue HandlerError => error
|
171
174
|
return response :internal_server_error,
|
@@ -49,7 +49,7 @@ class Toast::CollectionRequest
|
|
49
49
|
@auth, relation, @uri_params)
|
50
50
|
|
51
51
|
if relation.is_a?(ActiveRecord::Relation) and
|
52
|
-
relation.model == @config.base_model_class
|
52
|
+
relation.model.name == @config.base_model_class.name
|
53
53
|
|
54
54
|
result = relation.limit(window).offset(range_start)
|
55
55
|
|
@@ -80,7 +80,8 @@ class Toast::CollectionRequest
|
|
80
80
|
msg: "not authorized by allow block in: #{error.source_location}"
|
81
81
|
|
82
82
|
rescue BadRequest => error
|
83
|
-
response :bad_request, msg: "`#{error.message}' in: #{error.source_location}"
|
83
|
+
response :bad_request, msg: "`#{error.message}' in: #{error.source_location}",
|
84
|
+
headers: {'X-Toast-Error' => error.code}
|
84
85
|
|
85
86
|
rescue HandlerError => error
|
86
87
|
return response :internal_server_error,
|
@@ -139,7 +140,8 @@ class Toast::CollectionRequest
|
|
139
140
|
msg: "not authorized by allow block in: #{error.source_location}"
|
140
141
|
|
141
142
|
rescue BadRequest => error
|
142
|
-
response :bad_request, msg: "`#{error.message}' in: #{error.source_location}"
|
143
|
+
response :bad_request, msg: "`#{error.message}' in: #{error.source_location}",
|
144
|
+
headers: {'X-Toast-Error' => error.code}
|
143
145
|
|
144
146
|
rescue HandlerError => error
|
145
147
|
return response :internal_server_error,
|
data/lib/toast/errors.rb
CHANGED
@@ -24,9 +24,11 @@ module Toast::Errors
|
|
24
24
|
|
25
25
|
class BadRequest < StandardError
|
26
26
|
attr_accessor :source_location
|
27
|
+
attr_accessor :code
|
27
28
|
|
28
|
-
def initialize message, source_location
|
29
|
+
def initialize message, source_location, code = nil
|
29
30
|
@source_location = source_location
|
31
|
+
@code = code
|
30
32
|
super message
|
31
33
|
end
|
32
34
|
end
|
@@ -90,7 +90,8 @@ class Toast::PluralAssocRequest
|
|
90
90
|
msg: "exception raised in allow block: `#{error.orig_error.message}' in #{error.source_location}"
|
91
91
|
|
92
92
|
rescue BadRequest => error
|
93
|
-
response :bad_request, msg: "`#{error.message}' in: #{error.source_location}"
|
93
|
+
response :bad_request, msg: "`#{error.message}' in: #{error.source_location}",
|
94
|
+
headers: {'X-Toast-Error' => error.code}
|
94
95
|
|
95
96
|
rescue HandlerError => error
|
96
97
|
return response :internal_server_error,
|
@@ -159,7 +160,8 @@ class Toast::PluralAssocRequest
|
|
159
160
|
msg: "exception raised in allow block: `#{error.orig_error.message}' in #{error.source_location}"
|
160
161
|
|
161
162
|
rescue BadRequest => error
|
162
|
-
response :bad_request, msg: "`#{error.message}' in: #{error.source_location}"
|
163
|
+
response :bad_request, msg: "`#{error.message}' in: #{error.source_location}",
|
164
|
+
headers: {'X-Toast-Error' => error.code}
|
163
165
|
|
164
166
|
rescue HandlerError => error
|
165
167
|
return response :internal_server_error,
|
@@ -213,7 +215,8 @@ class Toast::PluralAssocRequest
|
|
213
215
|
response :not_found, msg: error.message
|
214
216
|
|
215
217
|
rescue BadRequest => error
|
216
|
-
response :bad_request, msg: "`#{error.message}' in: #{error.source_location}"
|
218
|
+
response :bad_request, msg: "`#{error.message}' in: #{error.source_location}",
|
219
|
+
headers: {'X-Toast-Error' => error.code}
|
217
220
|
|
218
221
|
rescue AllowError => error
|
219
222
|
return response :internal_server_error,
|
@@ -267,7 +270,8 @@ class Toast::PluralAssocRequest
|
|
267
270
|
msg: "exception raised in allow block: `#{error.orig_error.message}' in #{error.source_location}"
|
268
271
|
|
269
272
|
rescue BadRequest => error
|
270
|
-
response :bad_request, msg: "`#{error.message}' in: #{error.source_location}"
|
273
|
+
response :bad_request, msg: "`#{error.message}' in: #{error.source_location}",
|
274
|
+
headers: {'X-Toast-Error' => error.code}
|
271
275
|
|
272
276
|
rescue HandlerError => error
|
273
277
|
return response :internal_server_error,
|
@@ -122,8 +122,8 @@ module Toast::RequestHelpers
|
|
122
122
|
|
123
123
|
begin
|
124
124
|
context = Object.new
|
125
|
-
context.define_singleton_method(:bad_request) do |message|
|
126
|
-
raise Toast::Errors::BadRequest.new message, caller.first.sub(/:in.*/,'')
|
125
|
+
context.define_singleton_method(:bad_request) do |message, options = {}|
|
126
|
+
raise Toast::Errors::BadRequest.new message, caller.first.sub(/:in.*/,''), options[:code]
|
127
127
|
end
|
128
128
|
|
129
129
|
result = context.instance_exec *args, &proc
|
data/lib/toast/single_request.rb
CHANGED
@@ -49,7 +49,8 @@ class Toast::SingleRequest
|
|
49
49
|
msg: "exception raised in allow block: `#{error.orig_error.message}' in #{error.source_location}"
|
50
50
|
|
51
51
|
rescue BadRequest => error
|
52
|
-
response :bad_request, msg: "`#{error.message}' in: #{error.source_location}"
|
52
|
+
response :bad_request, msg: "`#{error.message}' in: #{error.source_location}",
|
53
|
+
headers: {'X-Toast-Error' => error.code}
|
53
54
|
|
54
55
|
rescue HandlerError => error
|
55
56
|
return response :internal_server_error,
|
@@ -58,7 +58,8 @@ class Toast::SingularAssocRequest
|
|
58
58
|
|
59
59
|
|
60
60
|
rescue BadRequest => error
|
61
|
-
response :bad_request, msg: "`#{error.message}' in: #{error.source_location}"
|
61
|
+
response :bad_request, msg: "`#{error.message}' in: #{error.source_location}",
|
62
|
+
headers: {'X-Toast-Error' => error.code}
|
62
63
|
|
63
64
|
rescue HandlerError => error
|
64
65
|
return response :internal_server_error,
|
@@ -120,7 +121,8 @@ class Toast::SingularAssocRequest
|
|
120
121
|
return response :unauthorized, msg: "not authorized by allow block in: #{error.source_location}"
|
121
122
|
|
122
123
|
rescue BadRequest => error
|
123
|
-
response :bad_request, msg: "`#{error.message}' in: #{error.source_location}"
|
124
|
+
response :bad_request, msg: "`#{error.message}' in: #{error.source_location}",
|
125
|
+
headers: {'X-Toast-Error' => error.code}
|
124
126
|
|
125
127
|
rescue HandlerError => error
|
126
128
|
return response :internal_server_error,
|
@@ -191,7 +193,8 @@ class Toast::SingularAssocRequest
|
|
191
193
|
msg: "not authorized by allow block in: #{error.source_location}"
|
192
194
|
|
193
195
|
rescue BadRequest => error
|
194
|
-
response :bad_request, msg: "`#{error.message}' in: #{error.source_location}"
|
196
|
+
response :bad_request, msg: "`#{error.message}' in: #{error.source_location}",
|
197
|
+
headers: {'X-Toast-Error' => error.code}
|
195
198
|
|
196
199
|
rescue HandlerError => error
|
197
200
|
return response :internal_server_error,
|
data/lib/toast/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: toast
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- robokopp (Robert Annies)
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-05-
|
11
|
+
date: 2019-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|