Closed
Description
tl;dr
Older versions of AMS had a filter
feature that older users are used to. We would like to bring this to 0.10.x.
Older versions of AMS had a filter
feature that older users are used to.
We would like to bring this to 0.10.x mainly for two reasons:
- There is no easy way to filter attributes on 0.10.x so far
- It will help ppl to update from 0.8 and 0.9
The idea is to provide a method named filter, which should return an array used to determine what attributes and associations should be included in the output. This is typically used to customize output based on current_user. For example:
class PostSerializer < ActiveModel::Serializer
attributes :id, :title, :body, :author
def filter(keys)
if scope.admin?
keys
else
keys - [:author]
end
end
end
related to issues:
related to PRs: