toast 0.8.9 → 0.8.10
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.
- data/app/controller/toast_controller.rb +3 -0
- data/lib/toast/association.rb +3 -1
- data/lib/toast/record.rb +1 -1
- data/lib/toast/resource.rb +1 -0
- data/lib/toast/version.rb +1 -1
- metadata +3 -3
@@ -31,6 +31,9 @@ class ToastController < ApplicationController
|
|
31
31
|
rescue Toast::ResourceNotAcceptable => e
|
32
32
|
return head(:not_acceptable)
|
33
33
|
|
34
|
+
rescue Toast::Conflict => e
|
35
|
+
return render :text => e.message, :status => :conflict
|
36
|
+
|
34
37
|
rescue Exception => e
|
35
38
|
log_exception e
|
36
39
|
puts e if Rails.env == "test"
|
data/lib/toast/association.rb
CHANGED
@@ -125,7 +125,6 @@ module Toast
|
|
125
125
|
end
|
126
126
|
|
127
127
|
def link link_path_info
|
128
|
-
|
129
128
|
slash, link_resource_name, link_id = link_path_info.split('/')
|
130
129
|
link_model = Resource.get_class_by_resource_name(link_resource_name)
|
131
130
|
link_record = link_model.find(link_id)
|
@@ -157,6 +156,9 @@ module Toast
|
|
157
156
|
raise Toast::ResourceNotAcceptable
|
158
157
|
rescue ActiveRecord::RecordNotFound
|
159
158
|
raise Toast::ResourceNotFound
|
159
|
+
rescue ActiveRecord::RecordInvalid, ActiveRecord::RecordNotSaved, ActiveRecord::RecordNotUnique => e
|
160
|
+
# model validation failed (join model used for linking)
|
161
|
+
raise PayloadInvalid.new(e.message)
|
160
162
|
end
|
161
163
|
|
162
164
|
def unlink link_path_info
|
data/lib/toast/record.rb
CHANGED
@@ -47,7 +47,7 @@ module Toast
|
|
47
47
|
unless (@record.respond_to?("#{vattr}=") && @record.method("#{vattr}=").arity == 1)
|
48
48
|
raise "Toast Error: Connot find setter '#{@record.class}##{vattr}='"
|
49
49
|
end
|
50
|
-
|
50
|
+
# FIXME: omitted virtual attributes are set to nil, omiited non-virtual attributes are ignored
|
51
51
|
@record.send("#{vattr}=", payload.delete(vattr))
|
52
52
|
end
|
53
53
|
|
data/lib/toast/resource.rb
CHANGED
@@ -3,6 +3,7 @@ module Toast
|
|
3
3
|
class ResourceNotFound < Exception; end
|
4
4
|
class MethodNotAllowed < Exception; end
|
5
5
|
class PayloadInvalid < Exception; end
|
6
|
+
class LinkInvalid < Exception; end
|
6
7
|
class PayloadFormatError < Exception; end
|
7
8
|
class UnsupportedMediaType < Exception; end
|
8
9
|
class RequestedVersionNotDefined < Exception; end
|
data/lib/toast/version.rb
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 8
|
8
|
-
-
|
9
|
-
version: 0.8.
|
8
|
+
- 10
|
9
|
+
version: 0.8.10
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- "robokopp (Robert Anni\xC3\xA9s)"
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2013-
|
17
|
+
date: 2013-09-16 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|