lib/materialist/materializer.rb in materialist-1.0.0 vs lib/materialist/materializer.rb in materialist-2.0.0
- old
+ new
@@ -188,11 +188,11 @@
return {} unless resource
mapping.inject({}) do |result, m|
case m
when FieldMapping
- result.tap { |r| r[m.as] = serializable_value(resource.body[m.key]) }
+ result.tap { |r| r[m.as] = resource.body[m.key] }
when LinkHrefMapping
result.tap do |r|
if resource.body._links.include?(m.key)
r[m.as] = resource.body._links[m.key].href
end
@@ -203,14 +203,9 @@
result
else
result
end
end
- end
-
- def serializable_value(value)
- value_is_complex_object = value.is_a?(Hash) || value.is_a?(Array)
- value_is_complex_object ? value.to_json : value
end
def resource_at(url)
api_client.get(url, options: { enable_caching: false })
rescue Routemaster::Errors::ResourceNotFound