toast 0.8.5 → 0.8.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.
- data/app/controller/toast_controller.rb +0 -1
- data/lib/toast/association.rb +4 -9
- data/lib/toast/collection.rb +4 -5
- data/lib/toast/record.rb +10 -8
- data/lib/toast/version.rb +1 -1
- metadata +4 -4
data/lib/toast/association.rb
CHANGED
@@ -88,15 +88,10 @@ module Toast
|
|
88
88
|
raise PayloadFormatError
|
89
89
|
end
|
90
90
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
((@associate_config_in.readables - @associate_config_in.writables) +
|
96
|
-
@associate_config_in.exposed_associations + ["self"]).each do |rof|
|
97
|
-
payload.delete(rof)
|
98
|
-
end
|
99
|
-
|
91
|
+
payload.delete_if {|key,value|
|
92
|
+
!@associate_config_in.writables.include?(key) or
|
93
|
+
@associate_config_in.exposed_associations.include?(key)
|
94
|
+
}
|
100
95
|
|
101
96
|
begin
|
102
97
|
reflection = @model.reflect_on_association(@assoc.to_sym)
|
data/lib/toast/collection.rb
CHANGED
@@ -91,11 +91,10 @@ module Toast
|
|
91
91
|
raise PayloadFormatError
|
92
92
|
end
|
93
93
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
94
|
+
payload.delete_if {|key,value|
|
95
|
+
!@config_in.writables.include?(key) or
|
96
|
+
@config_in.exposed_associations.include?(key)
|
97
|
+
}
|
99
98
|
|
100
99
|
begin
|
101
100
|
|
data/lib/toast/record.rb
CHANGED
@@ -34,13 +34,11 @@ module Toast
|
|
34
34
|
raise PayloadFormatError
|
35
35
|
end
|
36
36
|
|
37
|
-
# ignore
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
payload.delete(rof)
|
43
|
-
end
|
37
|
+
# ignore all not explicitly writable attribute
|
38
|
+
payload.delete_if {|key,value|
|
39
|
+
!@config_in.writables.include?(key) or
|
40
|
+
@config_in.exposed_associations.include?(key)
|
41
|
+
}
|
44
42
|
|
45
43
|
# set the virtual attributes
|
46
44
|
(@config_in.writables - @record.attribute_names - @config_in.exposed_associations).each do |vattr|
|
@@ -53,7 +51,7 @@ module Toast
|
|
53
51
|
end
|
54
52
|
|
55
53
|
# mass-update for the rest
|
56
|
-
@record.update_attributes payload
|
54
|
+
@record.update_attributes! payload
|
57
55
|
{
|
58
56
|
:json => @record.represent( @config_out.exposed_attributes,
|
59
57
|
@config_out.exposed_associations,
|
@@ -63,6 +61,10 @@ module Toast
|
|
63
61
|
:location => self.base_uri + @record.uri_path,
|
64
62
|
:content_type => @config_out.media_type
|
65
63
|
}
|
64
|
+
|
65
|
+
rescue ActiveRecord::RecordInvalid => e
|
66
|
+
# model validation failed
|
67
|
+
raise PayloadInvalid.new(e.message)
|
66
68
|
end
|
67
69
|
|
68
70
|
def get
|
data/lib/toast/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: toast
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 51
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 8
|
9
|
-
-
|
10
|
-
version: 0.8.
|
9
|
+
- 6
|
10
|
+
version: 0.8.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- "robokopp (Robert Anni\xC3\xA9s)"
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-09-
|
18
|
+
date: 2012-09-21 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: rails
|