2020-04-07 11:58:49 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class InvitedSerializer < ApplicationSerializer
|
2021-03-03 04:45:29 -05:00
|
|
|
attributes :invites, :can_see_invite_details, :counts
|
2020-04-07 11:58:49 -04:00
|
|
|
|
|
|
|
def invites
|
|
|
|
ActiveModel::ArraySerializer.new(
|
|
|
|
object.invite_list,
|
2021-03-06 06:29:35 -05:00
|
|
|
each_serializer: object.type == "pending" || object.type == "expired" ? InviteSerializer : InvitedUserSerializer,
|
2020-04-07 11:58:49 -04: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 04:45:29 -05:00
|
|
|
def counts
|
|
|
|
object.counts
|
2020-04-07 11:58:49 -04:00
|
|
|
end
|
|
|
|
end
|