Skip to content

Add conditional rendering of attributes and associations #22

Description

@Nitemaeric

I want to be able to conditionally include or exclude an attribute from my serializer output.

class Api::V1::UserSerializer < Transmutation::Serializer
  attribute :id, if: :admin?

  private

  def admin?
    current_user.admin?
  end
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions