sequel-jsonapi_eager 0.0.1 → 0.0.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7f90fa7b6e3f683a6a25a63901985bac74893597
4
- data.tar.gz: cf500a78f631337659560ee93f3c9511569d8fea
3
+ metadata.gz: 13bb547d4eccf7b9927130bd38b548ddb09b2eca
4
+ data.tar.gz: a786f85116def2322dbc9bb940500de26deefcaa
5
5
  SHA512:
6
- metadata.gz: 333cefb4fa6d1b2fbe327e77be20a2230f1d66c829ba2875591c7877be44d5d25d9cae7860e05294806619e3f0ac7f54f342f3f260d831a14ed4b4eb1c4576f3
7
- data.tar.gz: 3e8f33edb42496dccb4afc36ba51c3b1e39dedc2f4090bf16a533f1b86397518d92c5a148fe03b23b4fb496f8170152e662a38fc0a11d90dee548553f7c29cd8
6
+ metadata.gz: 3a7723c767bbefec38306f5f17a568ae25814e3e49dec73f4542a6eb64c601c3f958739315c3c6fbc60bc0171224a0ef2e0ef5de8843de576acdf41b45b0692d
7
+ data.tar.gz: d17f01de07da288d7d9fe8e26d5da85810101780827b7914ba257c995489f1ebf5750e41904dc5754635f2637420739f832767afa99baa09048578be7272c88f
@@ -24,7 +24,13 @@ module Sequel
24
24
  association_name, association_include = relationship.split(".", 2)
25
25
  association_dataset = send("#{association_name}_dataset")
26
26
  .jsonapi_eager(association_include.to_s)
27
- associations[association_name.to_sym] = association_dataset.all
27
+ association_reflection = self.class.association_reflections.fetch(association_name.to_sym)
28
+
29
+ if association_reflection[:type].to_s =~ /one$/
30
+ associations[association_name.to_sym] = association_dataset.all[0]
31
+ else
32
+ associations[association_name.to_sym] = association_dataset.all
33
+ end
28
34
  end
29
35
 
30
36
  self
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequel-jsonapi_eager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Janko Marohnić
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-12 00:00:00.000000000 Z
11
+ date: 2015-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sequel