Created
July 28, 2015 19:05
-
-
Save blackxored/84a175e58783159d330a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
normalize.each do |attribute, resource_name| | |
resource_class = find_resource_class(resource_name) | |
attr = attribute.to_s | |
if resource_class && resource_class.respond_to?(:find) | |
denormalize_resource = ->(child_resource) { | |
resource_class.find(child_resource) | |
} | |
results.each do |result| | |
if result[attr].kind_of?(Array) | |
result[attr].map!(&denormalize_resource) | |
else | |
result[attr] = denormalize_resource.call(result[attribute]) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment