-
Notifications
You must be signed in to change notification settings - Fork 89
Open
Description
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
endThe 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.
| show_attr &&= send(if_method_name) if if_method_name |
send(if_method_name, attribute_name)
Metadata
Metadata
Assignees
Labels
No labels