Skip to content

:if option for attribute method #922

Closed
@Le6ow5k1

Description

@Le6ow5k1

I think it would be nice to add an :if option for attribute method, so attribute will appear only if result of calling lambda specified at :if key is true.

class ActivitySerializer < ActiveModel::Serializer
  attribute :complete_till, if: -> { object.type == 'Task' }
end

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions