Skip to content

Commit 3939323

Browse files
author
Doug Smith
committed
fix: resolve issue JsonApiClient#352
1 parent 548e94f commit 3939323

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Unreleased
44

5+
- [#353](https://github.com/JsonApiClient/json_api_client/pull/353) - fix to support deserializing resources with relationships without those related resources being included in the response (issue [#352](https://github.com/JsonApiClient/json_api_client/issues/352)).
6+
57
## 1.14.0
68

79
- [#338](https://github.com/JsonApiClient/json_api_client/pull/338) - implement hash and eql? for builder class

lib/json_api_client/included_data.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@ def data_for(method_name, definition)
3636

3737
if data.is_a?(Array)
3838
# has_many link
39-
data.map do |link_def|
40-
record_for(link_def)
41-
end
39+
data.map(&method(:record_for)).compact
4240
else
4341
# has_one link
4442
record_for(data)
@@ -53,7 +51,8 @@ def has_link?(name)
5351

5452
# should return a resource record of some type for this linked document
5553
def record_for(link_def)
56-
data[link_def["type"]][link_def["id"]]
54+
record = data[link_def["type"]]
55+
record[link_def["id"]] if record
5756
end
5857
end
5958
end

0 commit comments

Comments
 (0)