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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3e568bcafb624da9ac84b8f85b975bba6ac051e7
4
- data.tar.gz: 33d3ba09653ace45e6cc31f5551d330517e85ba8
3
+ metadata.gz: 8efee4c4e9e7dc0b224b60a46f793a7484534b03
4
+ data.tar.gz: bfbe121a41e3e3bc7b26674012c2f79e07955ad0
5
5
  SHA512:
6
- metadata.gz: 589496fddcc6ffe77ab69c8104f6c8a73a472ceceb283767a70a6d07d1eab9aadef191f5a1e6f087360f9bf9b1adbdd8e8e99d904ccd2ff04c6b19aeeaad2d95
7
- data.tar.gz: 77d5e322883ed99681ddc466f898ed67f71254f888ce81357a96d1540d61aa4f7ad4418965dc8db63ed82dc26183a154f3dd92d9491e18f213cf5faeffbc5fba
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
- json.set! inc do
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
- if collection
14
- partial = model_partial(association.klass)
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
- else
17
- if record.send(inc).nil?
18
+ end
19
+ else
20
+
21
+ if record.send(inc).nil?
22
+ json.set! inc do
18
23
  json.null!
19
- else
20
- partial = model_partial(record.send(inc))
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
- json.set! inc do
27
- if record.send(inc).nil?
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.19
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-18 00:00:00.000000000 Z
11
+ date: 2015-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord-sort