toast 0.8.0 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/toast/association.rb +10 -5
- data/lib/toast/resource.rb +1 -1
- data/lib/toast/version.rb +1 -1
- metadata +4 -4
data/lib/toast/association.rb
CHANGED
@@ -3,8 +3,8 @@ module Toast
|
|
3
3
|
|
4
4
|
attr_reader :model
|
5
5
|
|
6
|
-
def initialize model, id, subresource_name, format, config, assoc_model, assoc_config_in, assoc_config_out
|
7
|
-
|
6
|
+
def initialize model, id, subresource_name, params, format, config, assoc_model, assoc_config_in, assoc_config_out
|
7
|
+
|
8
8
|
unless config.exposed_associations.include? subresource_name
|
9
9
|
raise ResourceNotFound
|
10
10
|
end
|
@@ -18,7 +18,7 @@ module Toast
|
|
18
18
|
@associate_model = assoc_model
|
19
19
|
@associate_config_in = assoc_config_in
|
20
20
|
@associate_config_out = assoc_config_out
|
21
|
-
|
21
|
+
@params = params
|
22
22
|
end
|
23
23
|
|
24
24
|
def get
|
@@ -27,11 +27,16 @@ module Toast
|
|
27
27
|
raise "Toast Error: Association '#{@assoc}' not found in model '#{@record.class}'"
|
28
28
|
end
|
29
29
|
|
30
|
-
result =
|
30
|
+
result =
|
31
|
+
if @config.pass_params_to.include?(@assoc)
|
32
|
+
@record.send(@assoc).find_by_params(@params)
|
33
|
+
else
|
34
|
+
@record.send(@assoc)
|
35
|
+
end
|
31
36
|
|
32
37
|
raise ResourceNotFound if result.nil?
|
33
38
|
|
34
|
-
if result.is_a? Array
|
39
|
+
if result.is_a? ActiveRecord::Relation or result.is_a? Array
|
35
40
|
{
|
36
41
|
:json => result.map{|r|
|
37
42
|
r.represent( @associate_config_out.in_collection.exposed_attributes,
|
data/lib/toast/resource.rb
CHANGED
@@ -64,7 +64,7 @@ module Toast
|
|
64
64
|
(assoc_config_out.namespace ? "/" + assoc_config_out.namespace : "")
|
65
65
|
|
66
66
|
|
67
|
-
Toast::Association.new(model, id, subresource_name, format, config_assoc_src,
|
67
|
+
Toast::Association.new(model, id, subresource_name, params.clone, format, config_assoc_src,
|
68
68
|
assoc_model, assoc_config_in, assoc_config_out)
|
69
69
|
|
70
70
|
else
|
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: 61
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 8
|
9
|
-
-
|
10
|
-
version: 0.8.
|
9
|
+
- 1
|
10
|
+
version: 0.8.1
|
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-08-
|
18
|
+
date: 2012-08-21 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: rails
|