Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #305: presenting arrays of objects when the entity class isn't explicitly passed into present #307

Merged
merged 1 commit into from
Jan 7, 2013
Merged

Conversation

brandonweiss
Copy link
Contributor

I wrote two failing specs and then refactored the code a little to make them pass. I tried to mirror the formatting as much as possible.

I had to manually create a named class in one place in order to properly create a failing test. Using Object wouldn't work because of the way present walks up the ancestor tree.

I also made an explicit choice to derive to auto-detect the entity from the first object in the collection because it was the simplest solution. It might make sense to expand it to auto-detect the entity of each object in the collection, in case someone returns a collection with different types of objects.

@dblock
Copy link
Member

dblock commented Jan 7, 2013

Merging. I think we can do a somewhat simpler logic around dealing with the Array, I'll take a quick stab at this.

dblock added a commit that referenced this pull request Jan 7, 2013
Fix #305: presenting arrays of objects when the entity class isn't explicitly passed into present
@dblock dblock merged commit f75b310 into ruby-grape:master Jan 7, 2013
@dblock
Copy link
Member

dblock commented Jan 7, 2013

I committed d3910e4, all I did is assign the object instance used to derive the Entity class and reuse it. This removes the need for the second ||=. Double-check after me, please.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants