jsonapi-consumer 0.1.0.pre.2 → 0.1.0.pre.3

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: 1c44382ce45f9e6375af4a33e129302baae53d16
4
- data.tar.gz: 47acb47a6f0e799782c7d6ed6923da2cfd69735c
3
+ metadata.gz: 1c1023158bad9c3f878f6c70c43de0030f33548f
4
+ data.tar.gz: e00a070c00e6dc4f013b7acb976fa38a3dab2b4d
5
5
  SHA512:
6
- metadata.gz: d2542085168cdf9a67f53b41d4fa0a8543b681e8703b828e72cc9c299732120c65eec114238bfbbff24f55e80348b10c1f9551cd79ce01e8a18341e0b4829f4c
7
- data.tar.gz: 7aafc9bb7f7b25b69465ab86787af082d1bd38fdf7c1451063b6695d39a564ae99fec6abcbb209755095e5f8fdd7bdde3c75826410521c7c319f27ecfe16ed39
6
+ metadata.gz: 576270b931a52c0b2813bd09a86a0352cd4b1ca9961ec4ed1cd923fc8f6a09076d03acd6879758c9c7c56f71851fba863cf53effd68b22c9a160adceafad2302
7
+ data.tar.gz: b8f8db8bb78d3dfd10c7b56206cf2419962a36a3c15c7f0f9ff0f9bb246bab4ecc8f9961a0c308de4ebb23f89669409c1c0b363999a8a0c04f063470b6bd9fbf
data/CHANGELOG.md CHANGED
@@ -1,4 +1,9 @@
1
1
 
2
+ 0.1.0.pre.3 / 2014-11-11
3
+ ==================
4
+
5
+ * Has One relationships use plural names in side-loading lookups.
6
+
2
7
  0.1.0.pre.2 / 2014-11-11
3
8
  ==================
4
9
 
@@ -40,7 +40,7 @@ module JSONAPI::Consumer
40
40
  end
41
41
 
42
42
  def find_linked(assoc_name, id)
43
- if found = linked.fetch(assoc_name, []).detect {|h| h.fetch(:id) == id }
43
+ if found = linked.fetch(assoc_name.pluralize, []).detect {|h| h.fetch(:id) == id }
44
44
  klass._association_class_name(assoc_name).new(found)
45
45
  else
46
46
  fetch_linked(assoc_name, id)
@@ -1,5 +1,5 @@
1
1
  module Jsonapi
2
2
  module Consumer
3
- VERSION = "0.1.0.pre.2"
3
+ VERSION = "0.1.0.pre.3"
4
4
  end
5
5
  end
@@ -21,10 +21,14 @@ module Blog
21
21
  end
22
22
 
23
23
  class Post < Base
24
- has_one :author, class_name: 'Blog::Author'
24
+ has_one :user, class_name: 'Blog::User'
25
25
  has_many :comments, class_name: 'Blog::Comment'
26
26
  end
27
27
 
28
+ class User < Base
29
+
30
+ end
31
+
28
32
  class Comment < Base
29
33
  # belongs_to :post, class_name: 'Blog::Post'
30
34
  # has_one :author, class_name: 'Blog::Author'
@@ -7,7 +7,8 @@ module Responses
7
7
  comments: [
8
8
  "82083863-bba9-480e-a281-f5d34e7dc0ca",
9
9
  "3b402e8a-7c35-4915-8c72-07ea7779ab76"
10
- ]
10
+ ],
11
+ user: "6a45992f-cd20-497a-a753-21b2a1a82356"
11
12
  },
12
13
  id: "e6d1b7ac-80d8-40dd-877d-f5bd40feabfb",
13
14
  title: "Friday Post",
@@ -19,7 +20,8 @@ module Responses
19
20
  comments: [
20
21
  "9c9ba83b-024c-4d4c-9573-9fd41b95fc14",
21
22
  "27fcf6e8-24b0-41db-94b1-812046a10f54"
22
- ]
23
+ ],
24
+ user: "d65dda70-73eb-461a-bb34-5484e6e8c194"
23
25
  },
24
26
  id: "ea006f14-6d05-4e87-bfe7-ee8ae3358840",
25
27
  title: "Monday Post",
@@ -28,6 +30,16 @@ module Responses
28
30
  }
29
31
  ],
30
32
  linked: {
33
+ users: [
34
+ {
35
+ id: "6a45992f-cd20-497a-a753-21b2a1a82356",
36
+ name: "Jane Smith"
37
+ },
38
+ {
39
+ id: "d65dda70-73eb-461a-bb34-5484e6e8c194",
40
+ name: "Jim Bob"
41
+ }
42
+ ],
31
43
  comments: [
32
44
  {
33
45
  id: "82083863-bba9-480e-a281-f5d34e7dc0ca",
@@ -44,7 +56,8 @@ module Responses
44
56
  ]
45
57
  },
46
58
  links: {
47
- :"posts.comments" => "http://localhost:3000/api/comments/{posts.comments}"
59
+ :"posts.comments" => "http://localhost:3000/api/comments/{posts.comments}",
60
+ :"posts.user" => "http://localhost:3000/api/comments/{posts.user}"
48
61
  }
49
62
  }.with_indifferent_access
50
63
  end
@@ -25,15 +25,13 @@ RSpec.describe 'Response Parsing' do
25
25
  ]
26
26
  }.to_json)
27
27
 
28
- # puts results.inspect
29
28
  expect(results.size).to eql(2)
30
29
 
31
30
  result = results.first
32
31
  expect(result.comments.size).to eql(2)
32
+ expect(result.user).to be_a(Blog::User)
33
33
 
34
34
  last = results.last
35
- expect(result.comments.size).to eql(2)
36
-
37
35
  expect(last.comments.first).to be_a(Blog::Comment)
38
36
  expect(last.comments.first.id).to eql("9c9ba83b-024c-4d4c-9573-9fd41b95fc14")
39
37
  expect(last.comments.first.content).to eql("i found this useful.")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsonapi-consumer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre.2
4
+ version: 0.1.0.pre.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Smestad