lib/materialist/materializer/internals/materializer.rb in materialist-3.1.0 vs lib/materialist/materializer/internals/materializer.rb in materialist-3.2.0
- old
+ new
@@ -132,19 +132,23 @@
r[m.as] = resource.body._links[m.key].href
end
end
when LinkMapping
resource.body._links.include?(m.key) ?
- result.merge(build_attributes(resource_at(resource.send(m.key).url), m.mapping || [])) :
+ result.merge(build_attributes(linked_resource(resource, m), m.mapping || [])) :
result
else
result
end
end
end
- def resource_at(url)
- api_client.get(url, options: { enable_caching: false })
+ def linked_resource(resource, mapping)
+ resource_at(resource.send(mapping.key).url, enable_caching: mapping.enable_caching)
+ end
+
+ def resource_at(url, enable_caching: false)
+ api_client.get(url, options: { enable_caching: enable_caching })
rescue Routemaster::Errors::ResourceNotFound
# this is due to a race condition between an upsert event
# and a :delete event
# when this happens we should silently ignore the case
nil