2020-04-07 10:58:49 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class InvitedSerializer < ApplicationSerializer
|
2021-03-03 03:45:29 -06:00
|
|
|
attributes :invites, :can_see_invite_details, :counts
|
2020-04-07 10:58:49 -05:00
|
|
|
|
|
|
|
def invites
|
|
|
|
ActiveModel::ArraySerializer.new(
|
|
|
|
object.invite_list,
|
2021-03-06 05:29:35 -06:00
|
|
|
each_serializer: object.type == "pending" || object.type == "expired" ? InviteSerializer : InvitedUserSerializer,
|
2020-04-07 10:58:49 -05:00
|
|
|
scope: scope,
|
|
|
|
root: false,
|
|
|
|
show_emails: object.show_emails
|
|
|
|
).as_json
|
|
|
|
end
|
|
|
|
|
|
|
|
def can_see_invite_details
|
|
|
|
scope.can_see_invite_details?(object.inviter)
|
|
|
|
end
|
|
|
|
|
2021-03-03 03:45:29 -06:00
|
|
|
def counts
|
|
|
|
object.counts
|
2020-04-07 10:58:49 -05:00
|
|
|
end
|
|
|
|
end
|