2018-11-19 21:01:13 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-01-09 15:46:38 -05:00
|
|
|
module Gitlab
|
|
|
|
module View
|
|
|
|
module Presenter
|
|
|
|
class Factory
|
|
|
|
def initialize(subject, **attributes)
|
|
|
|
@subject = subject
|
|
|
|
@attributes = attributes
|
|
|
|
end
|
|
|
|
|
|
|
|
def fabricate!
|
2020-10-12 20:08:42 -04:00
|
|
|
presenter_class.new(subject, **attributes)
|
2017-01-09 15:46:38 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2017-01-10 17:41:04 -05:00
|
|
|
attr_reader :subject, :attributes
|
|
|
|
|
2017-01-09 15:46:38 -05:00
|
|
|
def presenter_class
|
2017-12-05 09:03:16 -05:00
|
|
|
attributes.delete(:presenter_class) { "#{subject.class.name}Presenter".constantize }
|
2017-01-09 15:46:38 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|