toast 0.8.2 → 0.8.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/toast/association.rb +11 -8
- data/lib/toast/collection.rb +1 -1
- data/lib/toast/record.rb +1 -1
- data/lib/toast/version.rb +1 -1
- metadata +10 -10
data/lib/toast/association.rb
CHANGED
@@ -27,8 +27,12 @@ module Toast
|
|
27
27
|
raise "Toast Error: Association '#{@assoc}' not found in model '#{@record.class}'"
|
28
28
|
end
|
29
29
|
|
30
|
+
reflection = @model.reflect_on_association(@assoc.to_sym)
|
31
|
+
|
30
32
|
result =
|
31
|
-
if
|
33
|
+
if(@config.pass_params_to.include?(@assoc) and
|
34
|
+
reflection.options[:extend] and
|
35
|
+
reflection.options[:extend].detect{|e| e.method_defined? :find_by_params} )
|
32
36
|
@record.send(@assoc).find_by_params(@params)
|
33
37
|
else
|
34
38
|
@record.send(@assoc)
|
@@ -58,6 +62,9 @@ module Toast
|
|
58
62
|
}
|
59
63
|
end
|
60
64
|
|
65
|
+
|
66
|
+
rescue ActiveRecord::RecordNotFound
|
67
|
+
raise ResourceNotFound
|
61
68
|
end
|
62
69
|
|
63
70
|
def put payload, media_type
|
@@ -144,7 +151,7 @@ module Toast
|
|
144
151
|
|
145
152
|
{
|
146
153
|
:nothing => true,
|
147
|
-
:status => :
|
154
|
+
:status => :no_content
|
148
155
|
}
|
149
156
|
|
150
157
|
rescue ActiveRecord::AssociationTypeMismatch
|
@@ -173,14 +180,10 @@ module Toast
|
|
173
180
|
|
174
181
|
{
|
175
182
|
:nothing => true,
|
176
|
-
:status => :
|
183
|
+
:status => :no_content
|
177
184
|
}
|
178
185
|
rescue ActiveRecord::RecordNotFound
|
179
|
-
|
180
|
-
{
|
181
|
-
:nothing => true,
|
182
|
-
:status => :ok
|
183
|
-
}
|
186
|
+
raise ResourceNotFound
|
184
187
|
end
|
185
188
|
end
|
186
189
|
end
|
data/lib/toast/collection.rb
CHANGED
@@ -92,7 +92,7 @@ module Toast
|
|
92
92
|
end
|
93
93
|
|
94
94
|
# silently ignore all exposed readable, but not writable fields
|
95
|
-
(@config_in.readables - @config_in.writables + ["self"]).each do |rof|
|
95
|
+
((@config_in.readables - @config_in.writables) + @config_in.exposed_associations + ["self"]).each do |rof|
|
96
96
|
payload.delete(rof)
|
97
97
|
end
|
98
98
|
|
data/lib/toast/record.rb
CHANGED
data/lib/toast/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: toast
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-09-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
16
|
-
requirement: &
|
16
|
+
requirement: &70107922198960 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 3.1.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70107922198960
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: blockenspiel
|
27
|
-
requirement: &
|
27
|
+
requirement: &70107922198460 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 0.4.2
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70107922198460
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rack-accept-media-types
|
38
|
-
requirement: &
|
38
|
+
requirement: &70107922198000 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0.9'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70107922198000
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: ffaker
|
49
|
-
requirement: &
|
49
|
+
requirement: &70107922197620 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70107922197620
|
58
58
|
description: ! 'Toast is an extension to Ruby on Rails that lets you expose any
|
59
59
|
|
60
60
|
ActiveRecord model as a resource according to the REST paradigm via a generic controller.
|