We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hi guys, I had a problem when trying to do something like this
class GroupUserSerializer < ApplicationSerializer attributes = %i[example1 example2] attributes.each { |attr| attribute attr, if: :attr_authorized? } def attr_authorized? attr_name == :example2 end
The problem is that mi method attr_authorized? doesn't have access to the name of the attr in the iteration.
attr_authorized?
Researching a little in the source code, I saw that the method in charge of executing the if option is should_include_attr?
if
It would be a good idea to allow to send the attribute_name, in case it is necessary like my case.
attribute_name
jsonapi-serializers/lib/jsonapi-serializers/serializer.rb
Line 217 in db48bdf
send(if_method_name, attribute_name)
The text was updated successfully, but these errors were encountered:
We should probably send formatted_attribute_name and attr_data. EDIT: ...and to the unless method as well.
formatted_attribute_name
attr_data
Sorry, something went wrong.
No branches or pull requests
Hi guys, I had a problem when trying to do something like this
The problem is that mi method
attr_authorized?
doesn't have access to the name of the attr in the iteration.Researching a little in the source code, I saw that the method in charge of executing the
if
option is should_include_attr?It would be a good idea to allow to send the
attribute_name
, in case it is necessary like my case.jsonapi-serializers/lib/jsonapi-serializers/serializer.rb
Line 217 in db48bdf
send(if_method_name, attribute_name)
The text was updated successfully, but these errors were encountered: