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-01-10 22:41:04 +00:00
|
|
|
"#{subject.class.name}Presenter".constantize
|
2017-01-09 20:46:38 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|