-
Notifications
You must be signed in to change notification settings - Fork 152
implement universally unique attributes to silo exposure logic #90
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
Conversation
@@ -12,3 +12,25 @@ | |||
RSpec.configure do |config| | |||
config.raise_errors_for_deprecations! | |||
end | |||
|
|||
module Grape |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For sanity sake we should organize these things into spec/support
, so spec/support/grape/entity.rb
.
I think this looks really good. It needs possibly README and definitely CHANGELOG updates, and a squash, please. |
I wonder whether an implementation that stores an array of exposures instead of uniquely labeled ones would be cleaner. This way you would have a Hash of attribute => exposures. Either way this is a good step forward, especially that there're now tests for this kind of stuff. |
Bump @wyattisimo. |
@dblock Sorry, been a bit busy. I think you're right about an array of exposures being cleaner. I'll get to it this week. |
@wyattisimo hey, looks great 👍 . Looking forward for updates 😄. |
@dblock finally had time to get back to this. implemented array of exposures for each attribute. all tests are passing. |
@dblock okay, upstream conflicts should be resolved. let me know what you think. i'll squash and update README and CHANGELOG once it's finalized |
This looks good to me, squash/rebase/etc.? |
What's going on? |
There're quite a few merge conflicts that need to be looked at carefully, bump @wyattisimo. |
Sorry for the delay! Been busy with other things and stuff and things... I'll try to get this wrapped up in the next few days. |
Maybe I can help to squash these commits, there are quite a few merge conflicts and need to change something for the new commits. |
Hi! Please look at the work done in #151 — it solves this problem differently and without performance degradation. It's not released yet and will go to 0.5.0 but you can try it out from current master. |
Here's my first stab at issue #52. It silos exposure logic by creating a universally unique attribute for each exposure.
It allows for stuff like this to work properly:
This ended up requiring more tweaking than I expected. I also had to modify a number of specs that are accessing certain protected methods that now require a unique attribute (like
value_for
).I added specs to test applying "if" conditions to an attribute in separate exposure declarations, and all existing specs are currently passing, but there are likely some new use cases and/or side effects that need to be discussed/resolved.
EDIT
Just for clarification... using the above exposure declarations, grape-entity currently produces the following exposures hash:
With this update, those same exposure declarations will result in an exposures hash like this: