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

28 lines
758 B
Ruby
Raw Normal View History

2019-12-21 20:55:43 +05:30
# frozen_string_literal: true
class DiffsMetadataEntity < DiffsEntity
unexpose :diff_files
2021-02-22 17:27:13 +05:30
expose :diff_files, using: DiffFileMetadataEntity do |diffs, _|
diffs.raw_diff_files(sorted: true)
end
2020-10-24 23:57:45 +05:30
expose :conflict_resolution_path do |_, options|
presenter(options[:merge_request]).conflict_resolution_path
end
expose :has_conflicts do |_, options|
options[:merge_request].cannot_be_merged?
end
expose :can_merge do |_, options|
options[:merge_request].can_be_merged_by?(request.current_user)
end
private
def presenter(merge_request)
@presenters ||= {}
@presenters[merge_request] ||= MergeRequestPresenter.new(merge_request, current_user: request.current_user) # rubocop: disable CodeReuse/Presenter
end
2019-12-21 20:55:43 +05:30
end