-
Notifications
You must be signed in to change notification settings - Fork 538
Allow more control over allowing includes #1096
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
82c15b9
to
8bd7b42
Compare
lib/jsonapi/relationship.rb
Outdated
"#{name}_type" if polymorphic? | ||
end | ||
|
||
def allow_include? |
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.
This is awesome, would be cool to have the context passed in, similarly to fetchable_fields useful to remove some depending on the current user.
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.
@joegaudet Good idea
Replaces `allow_includes` with `default_allow_include_to_one` and `default_allow_include_to_many` configuration options. Adds support for `allow_include` option on Relationships to override the config settings.
8bd7b42
to
b6a05fb
Compare
Updated for @joegaudet so you can now provide a boolean, a callable name, or a lambda for |
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.
Looks pretty good. Needs one simple fix. I'd also feel more comfortable if the recursion logic in check_include
were tested.
Deprecates and replaces the
allow_include
config optionReplaces
allow_includes
withdefault_allow_include_to_one
anddefault_allow_include_to_many
configuration options.Adds support for
allow_include
option on Relationships to override the config settings.Purpose: