Skip to content

Bringing Filter to 0.10.x #1058

Closed
Closed
@joaomdmoura

Description

@joaomdmoura

tl;dr

Older versions of AMS had a filterfeature that older users are used to. We would like to bring this to 0.10.x.


Older versions of AMS had a filterfeature that older users are used to.
We would like to bring this to 0.10.x mainly for two reasons:

  1. There is no easy way to filter attributes on 0.10.x so far
  2. 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:

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions