toast 1.1.2 → 1.1.6
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 +5 -5
- data/lib/toast/collection_request.rb +1 -1
- data/lib/toast/config_dsl/base.rb +1 -1
- data/lib/toast/plural_assoc_request.rb +5 -5
- data/lib/toast/rack_app.rb +1 -1
- data/lib/toast/request_helpers.rb +1 -1
- data/lib/toast/singular_assoc_request.rb +2 -2
- data/lib/toast/version.rb +1 -1
- data/lib/toast.rb +1 -1
- metadata +6 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 6692615b00bca742bd0efb94bc2a4636881c5c71761f2f2fedf2d08ee640e99d
|
|
4
|
+
data.tar.gz: 4e076fba2705931d64bba25dd75090c1d8e7d7317cdd0f2aaf07d92c79ea304b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e38ed6e2b1b87faabeef54d87a8a538eeb86931b48d067bbfd73a1195740a8a6bb28311d118fb604fa47cf5f66949accd9051add2f0ed701cdf155d1c639f521
|
|
7
|
+
data.tar.gz: 19c475e42ffdf0052247dd9ed05786fddb12d88b6228f7895d59b40e7b29fc66face6662d5d051dac0be09b821ff7133b1b8a554fc20dce5ef07a12d729c9c1b
|
|
@@ -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
|
|
|
@@ -64,7 +64,7 @@ class Toast::ConfigDSL::Base
|
|
|
64
64
|
self.associations = {}
|
|
65
65
|
end
|
|
66
66
|
|
|
67
|
-
if Toast.expositions.detect{|exp| exp.model_class == config_data.model_class}
|
|
67
|
+
if Toast.expositions.detect{|exp| exp.model_class.name == config_data.model_class.name}
|
|
68
68
|
raise_config_error "Model class #{exp.model_class} has already another configuration."
|
|
69
69
|
end
|
|
70
70
|
|
|
@@ -53,7 +53,7 @@ class Toast::PluralAssocRequest
|
|
|
53
53
|
source = @base_config.model_class.find(@id) # may raise ActiveRecord::RecordNotFound
|
|
54
54
|
relation = call_handler(@config.via_get.handler, source, @uri_params) # may raise HandlerError
|
|
55
55
|
|
|
56
|
-
unless relation.is_a? ActiveRecord::Relation and relation.model == @config.target_model_class
|
|
56
|
+
unless relation.is_a? ActiveRecord::Relation and relation.model.name == @config.target_model_class.name
|
|
57
57
|
return response :internal_server_error,
|
|
58
58
|
msg: "plural association handler returned `#{relation.class}', expected `ActiveRecord::Relation' (#{@config.target_model_class})"
|
|
59
59
|
end
|
|
@@ -207,7 +207,7 @@ class Toast::PluralAssocRequest
|
|
|
207
207
|
call_handler(@config.via_link.handler, source, target, @uri_params)
|
|
208
208
|
|
|
209
209
|
response :ok,
|
|
210
|
-
msg: "linked #{target_model_class.name}##{
|
|
210
|
+
msg: "linked #{target_model_class.name}##{target_id} with #{source.class}##{source.id}.#{@config.assoc_name}",
|
|
211
211
|
body: Toast.settings.link_unlink_via_post ? '' : nil
|
|
212
212
|
|
|
213
213
|
rescue ActiveRecord::RecordNotFound => error
|
|
@@ -247,7 +247,7 @@ class Toast::PluralAssocRequest
|
|
|
247
247
|
return response :bad_request, msg: "Link header missing or invalid"
|
|
248
248
|
end
|
|
249
249
|
|
|
250
|
-
name,
|
|
250
|
+
name, target_id = split_link_header(link)
|
|
251
251
|
target_model_class = name.singularize.classify.constantize
|
|
252
252
|
|
|
253
253
|
unless is_active_record? target_model_class
|
|
@@ -255,10 +255,10 @@ class Toast::PluralAssocRequest
|
|
|
255
255
|
end
|
|
256
256
|
|
|
257
257
|
call_allow(@config.via_unlink.permissions, @auth, source, @uri_params)
|
|
258
|
-
call_handler(@config.via_unlink.handler, source, target_model_class.find(
|
|
258
|
+
call_handler(@config.via_unlink.handler, source, target_model_class.find(target_id), @uri_params)
|
|
259
259
|
|
|
260
260
|
response :ok,
|
|
261
|
-
msg: "unlinked #{target_model_class.name}##{
|
|
261
|
+
msg: "unlinked #{target_model_class.name}##{target_id} from #{source.class}##{source.id}.#{@config.assoc_name}",
|
|
262
262
|
body: Toast.settings.link_unlink_via_post ? '' : nil
|
|
263
263
|
|
|
264
264
|
rescue ActiveRecord::RecordNotFound => error
|
data/lib/toast/rack_app.rb
CHANGED
|
@@ -18,7 +18,7 @@ class Toast::RackApp
|
|
|
18
18
|
request = ActionDispatch::Request.new(env)
|
|
19
19
|
Toast.request = request
|
|
20
20
|
|
|
21
|
-
Toast.logger.info "processing: <#{request.method} #{
|
|
21
|
+
Toast.logger.info "processing: <#{request.method} #{CGI.unescape(request.fullpath)}>"
|
|
22
22
|
|
|
23
23
|
# Authentication: respond with 401 on exception or falsy return value:
|
|
24
24
|
begin
|
|
@@ -107,7 +107,7 @@ class Toast::SingularAssocRequest
|
|
|
107
107
|
return response :not_found, msg: "target class `#{target_model_class.name}' is not an `ActiveRecord'"
|
|
108
108
|
end
|
|
109
109
|
|
|
110
|
-
if target_model_class != @config.target_model_class
|
|
110
|
+
if target_model_class.name != @config.target_model_class.name
|
|
111
111
|
return response :bad_request,
|
|
112
112
|
msg: "target class `#{target_model_class.name}' invalid, expect: `#{@config.target_model_class}'"
|
|
113
113
|
end
|
|
@@ -164,7 +164,7 @@ class Toast::SingularAssocRequest
|
|
|
164
164
|
return response :not_found, msg: "target class `#{target_model_class.name}' is not an `ActiveRecord'"
|
|
165
165
|
end
|
|
166
166
|
|
|
167
|
-
if target_model_class != @config.target_model_class
|
|
167
|
+
if target_model_class.name != @config.target_model_class.name
|
|
168
168
|
return response :bad_request,
|
|
169
169
|
msg: "target class `#{target_model_class.name}' invalid, expect: `#{@config.target_model_class}'"
|
|
170
170
|
end
|
data/lib/toast/version.rb
CHANGED
data/lib/toast.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.1.
|
|
4
|
+
version: 1.1.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- robokopp (Robert Annies)
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2022-01-25 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|
|
@@ -79,7 +79,7 @@ homepage: https://github.com/robokopp/toast
|
|
|
79
79
|
licenses:
|
|
80
80
|
- MIT
|
|
81
81
|
metadata: {}
|
|
82
|
-
post_install_message:
|
|
82
|
+
post_install_message:
|
|
83
83
|
rdoc_options: []
|
|
84
84
|
require_paths:
|
|
85
85
|
- lib
|
|
@@ -94,9 +94,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
94
94
|
- !ruby/object:Gem::Version
|
|
95
95
|
version: '0'
|
|
96
96
|
requirements: []
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
signing_key:
|
|
97
|
+
rubygems_version: 3.2.22
|
|
98
|
+
signing_key:
|
|
100
99
|
specification_version: 4
|
|
101
100
|
summary: Toast exposes ActiveRecord models as a web service (REST API).
|
|
102
101
|
test_files: []
|