blob: 0fbb10307cf14ada7e4f78d5e31e2bbf5cd89b5d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
# frozen_string_literal: true
module API
module Entities
class UserSafe < Grape::Entity
include RequestAwareEntity
expose :id, documentation: { type: 'integer', example: 1 }
expose :username, documentation: { type: 'string', example: 'admin' }
expose :name, documentation: { type: 'string', example: 'Administrator' } do |user|
current_user = request.respond_to?(:current_user) ? request.current_user : options.fetch(:current_user, nil)
user.redacted_name(current_user)
end
end
end
end
|