standardapi 1.0.19 → 1.0.20
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/standard_api/views/application/_record.json.jbuilder +29 -12
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8efee4c4e9e7dc0b224b60a46f793a7484534b03
|
4
|
+
data.tar.gz: bfbe121a41e3e3bc7b26674012c2f79e07955ad0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc900a2e9e417ae3a5c3d3067c5fb833e83ff647f9f7433a2b443c1c458c12ebf5e653e4414155bdb798e7df397bcd43c59e9935fde5afcc38eff12e50e1282c
|
7
|
+
data.tar.gz: ea1883e5531ebb73ee3973002165dc714e0a19c89a4d984a2c26d88695d0f6299f893554256a74a578c7a5c621f09e02ab1648ddeb8d19ee0b4a4d9fa95d6df0
|
@@ -5,32 +5,49 @@ record.attributes.each do |name, value|
|
|
5
5
|
end
|
6
6
|
|
7
7
|
includes.each do |inc, subinc|
|
8
|
+
|
9
|
+
|
8
10
|
association = record.class.reflect_on_association(inc)
|
9
11
|
if association
|
10
|
-
|
11
|
-
collection = [:has_many, :has_and_belongs_to_many].include?(association.macro)
|
12
|
+
collection = [:has_many, :has_and_belongs_to_many].include?(association.macro)
|
12
13
|
|
13
|
-
|
14
|
-
|
14
|
+
if collection
|
15
|
+
partial = model_partial(association.klass)
|
16
|
+
json.set! inc do
|
15
17
|
json.array! record.send(inc), partial: partial, as: partial.split('/').last, locals: { includes: subinc }
|
16
|
-
|
17
|
-
|
18
|
+
end
|
19
|
+
else
|
20
|
+
|
21
|
+
if record.send(inc).nil?
|
22
|
+
json.set! inc do
|
18
23
|
json.null!
|
19
|
-
|
20
|
-
|
24
|
+
end
|
25
|
+
else
|
26
|
+
partial = model_partial(record.send(inc))
|
27
|
+
json.set! inc do
|
21
28
|
json.partial! partial, partial.split('/').last.to_sym => record.send(inc), includes: subinc
|
22
29
|
end
|
23
30
|
end
|
24
31
|
end
|
32
|
+
|
25
33
|
else
|
26
|
-
|
27
|
-
|
34
|
+
|
35
|
+
if record.send(inc).nil?
|
36
|
+
json.set! inc do
|
28
37
|
json.null!
|
29
|
-
else
|
30
|
-
record.send(inc).as_json
|
31
38
|
end
|
39
|
+
elsif record.send(inc).is_a?(ActiveModel::Model)
|
40
|
+
partial = model_partial(record.send(inc))
|
41
|
+
json.set! inc do
|
42
|
+
json.partial! partial, partial.split('/').last.to_sym => record.send(inc), includes: subinc
|
43
|
+
end
|
44
|
+
else
|
45
|
+
# TODO: Test
|
46
|
+
json.set! inc, record.send(inc).as_json
|
32
47
|
end
|
48
|
+
|
33
49
|
end
|
50
|
+
|
34
51
|
end
|
35
52
|
|
36
53
|
if !record.errors.blank?
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: standardapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.20
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Bracy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord-sort
|