debian-mirror-gitlab/app/serializers/suggestion_entity.rb

22 lines
515 B
Ruby
Raw Normal View History

2019-02-15 15:39:39 +05:30
# frozen_string_literal: true
class SuggestionEntity < API::Entities::Suggestion
include RequestAwareEntity
2019-07-07 11:18:12 +05:30
unexpose :from_line, :to_line, :from_content, :to_content
2020-03-09 13:42:32 +05:30
expose :diff_lines, using: DiffLineEntity do |suggestion|
Gitlab::Diff::Highlight.new(suggestion.diff_lines).highlight
end
2019-02-15 15:39:39 +05:30
expose :current_user do
expose :can_apply do |suggestion|
Ability.allowed?(current_user, :apply_suggestion, suggestion)
end
end
private
def current_user
request.current_user
end
end