Skip to content

Commit e84414f

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

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

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)