2016-09-24 11:00:46 +08:00
|
|
|
# frozen_string_literal: true
|
2017-11-25 11:23:47 -08:00
|
|
|
|
2016-09-22 01:22:40 +08:00
|
|
|
module Api
|
|
|
|
module V2
|
|
|
|
class UserSerializer < ApplicationSerializer
|
|
|
|
attributes :id,
|
2016-09-24 11:00:46 +08:00
|
|
|
:name,
|
|
|
|
:avatar,
|
|
|
|
:generation
|
2016-09-22 01:22:40 +08:00
|
|
|
|
2016-10-04 22:24:47 +08:00
|
|
|
attribute :is_admin,
|
2016-10-29 22:58:31 +08:00
|
|
|
if: -> { scope[:show_full_user] && scope[:current_user] == object }
|
|
|
|
attribute :email,
|
|
|
|
if: -> { scope[:show_full_user] && scope[:current_user] == object }
|
2016-10-04 22:24:47 +08:00
|
|
|
|
2016-09-22 01:22:40 +08:00
|
|
|
def avatar
|
|
|
|
object.image.url(:sixtyfour)
|
|
|
|
end
|
|
|
|
|
|
|
|
def is_admin
|
|
|
|
object.admin
|
|
|
|
end
|
2016-09-24 12:27:34 +08:00
|
|
|
# rubocop:enable Style/PredicateName
|
2016-09-22 01:22:40 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|