You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I know this has partially been reported already #171 but I think what proposed @ribordy is kinda nice. I would even imagine one step further like
classDemoResourceattribute:name,:string,readable: :readable?,writable: :writable?attribute:role:string,readable: :readable?,writable: :writable?defreadable?(attr)policy(model_instance).permitted_read_attributes.include?(attr)enddefwritable?(attr)policy(model_instance).permitted_write_attributes.include?(attr)endendclassDemoPolicydefindex# some logicenddefupdate# some logicenddefpermitted_read_attributes=%i[namerole]defpermitted_write_attributesifuser.admin?%i[namerole]else%i[name]endendend
That way we can leverage Pundit for what they call "permitted_attributes" too and have the read+write permissions at the same place => in the policy file, where I think it belongs.
Activity
jkeen commentedon Mar 18, 2025
@ghn I think this would be great. Do you have time to work up a PR?
ghn commentedon Apr 13, 2025
While I was digging the code to add the feature, I found out that it's already there 😂 only the documentation is not up to date.
We can do
readable?accepts zero, one or two arguments, see: https://github.com/graphiti-api/graphiti/blob/main/lib/graphiti/util/serializer_attributes.rb#L85However the
writablemethod does not accept any argument yet :(jkeen commentedon Jul 29, 2026
@ghn released in v1.12.0