metamaps--metamaps/app/serializers/api/v2/user_serializer.rb
2016-10-04 22:51:21 +08:00

24 lines
535 B
Ruby

# frozen_string_literal: true
module Api
module V2
class UserSerializer < ApplicationSerializer
attributes :id,
:name,
:avatar,
:generation
attribute :is_admin,
if: -> { scope[:show_is_admin] && scope[:current_user] == object }
def avatar
object.image.url(:sixtyfour)
end
# rubocop:disable Style/PredicateName
def is_admin
object.admin
end
# rubocop:enable Style/PredicateName
end
end
end