2019-05-03 06:17:27 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2013-02-06 03:16:51 +08:00
|
|
|
class InviteSerializer < ApplicationSerializer
|
|
|
|
|
2019-11-26 15:52:48 +08:00
|
|
|
attributes :email, :updated_at, :redeemed_at, :expired, :user
|
2013-02-06 03:16:51 +08:00
|
|
|
|
|
|
|
def include_email?
|
2020-03-05 00:47:09 +08:00
|
|
|
options[:show_emails] && !object.redeemed?
|
2013-02-06 03:16:51 +08:00
|
|
|
end
|
|
|
|
|
2014-01-22 04:13:55 +08:00
|
|
|
def expired
|
|
|
|
object.expired?
|
|
|
|
end
|
|
|
|
|
2014-03-22 02:13:04 +08:00
|
|
|
def user
|
|
|
|
ser = InvitedUserSerializer.new(object.user, scope: scope, root: false)
|
|
|
|
ser.invited_by = object.invited_by
|
|
|
|
ser.as_json
|
|
|
|
end
|
|
|
|
|
2013-02-06 03:16:51 +08:00
|
|
|
end
|