summaryrefslogtreecommitdiff
path: root/app/presenters/clusterable_presenter.rb
blob: c857d57b003408fbecf6070429af50e808b9c639 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# frozen_string_literal: true

class ClusterablePresenter < Gitlab::View::Presenter::Delegated
  presents :clusterable

  def self.fabricate(clusterable, **attributes)
    presenter_class = "#{clusterable.class.name}ClusterablePresenter".constantize
    attributes_with_presenter_class = attributes.merge(presenter_class: presenter_class)

    Gitlab::View::Presenter::Factory
      .new(clusterable, attributes_with_presenter_class)
      .fabricate!
  end

  def can_create_cluster?
    can?(current_user, :create_cluster, clusterable)
  end

  def index_path
    raise NotImplementedError
  end

  def new_path
    raise NotImplementedError
  end

  def clusterable_params
    raise NotImplementedError
  end
end