debian-mirror-gitlab/lib/gitlab/view/presenter/factory.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

27 lines
535 B
Ruby
Raw Normal View History

2018-12-23 12:14:25 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
module Gitlab
module View
module Presenter
class Factory
def initialize(subject, **attributes)
@subject = subject
@attributes = attributes
end
def fabricate!
2021-01-03 14:25:43 +05:30
presenter_class.new(subject, **attributes)
2017-08-17 22:00:37 +05:30
end
private
attr_reader :subject, :attributes
def presenter_class
2018-03-17 18:26:18 +05:30
attributes.delete(:presenter_class) { "#{subject.class.name}Presenter".constantize }
2017-08-17 22:00:37 +05:30
end
end
end
end
end