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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 4bb1bbbff5062a7c3ff06f3e0f4811fa4a5a19ff
4
- data.tar.gz: 92fd188d895680cd439e37d21f34404601d8d2f4
2
+ SHA256:
3
+ metadata.gz: 6692615b00bca742bd0efb94bc2a4636881c5c71761f2f2fedf2d08ee640e99d
4
+ data.tar.gz: 4e076fba2705931d64bba25dd75090c1d8e7d7317cdd0f2aaf07d92c79ea304b
5
5
  SHA512:
6
- metadata.gz: 1d5bfdd1c56a5358d7ca2c5765e015b09824ac2b7de5c81e2d117b493021d5a126d72e1113d23d8e35c4e7e4e87c08e3eac52be22cc3d287da557f528f896b50
7
- data.tar.gz: 4c1f727e96e1abe9dce531e9896848e2f44214e686c0aa2f8f2fc0bdfd670b8f0829784caf8ca334d361f7a1c04deb3ce720545d6487d3ee50a24bf8f9545989
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}##{@id} with #{source.class}##{source.id}.#{@config.assoc_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, id = split_link_header(link)
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(id), @uri_params)
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}##{id} from #{source.class}##{source.id}.#{@config.assoc_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
@@ -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} #{URI.decode(request.fullpath)}>"
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
@@ -4,7 +4,7 @@ module Toast::RequestHelpers
4
4
 
5
5
  def get_config model_class
6
6
  Toast.expositions.detect do |exp|
7
- exp.model_class == model_class
7
+ exp.model_class.name == model_class.name
8
8
  end || raise(Toast::Errors::ConfigNotFound)
9
9
  end
10
10
 
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Toast
2
- VERSION = '1.1.2'
2
+ VERSION = '1.1.6'
3
3
  end
data/lib/toast.rb CHANGED
@@ -30,7 +30,7 @@ module Toast
30
30
 
31
31
  settings = ''
32
32
  # read global settings
33
- if File.exists? settings_path
33
+ if File.exist? settings_path
34
34
  open settings_path do |f|
35
35
  settings = f.read
36
36
  end
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.2
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: 2019-05-20 00:00:00.000000000 Z
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
- rubyforge_project:
98
- rubygems_version: 2.5.2.3
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: []