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