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