debian-mirror-gitlab/lib/gitlab/view/presenter/factory.rb
2019-02-13 22:33:31 +05:30

26 lines
533 B
Ruby

# frozen_string_literal: true
module Gitlab
module View
module Presenter
class Factory
def initialize(subject, **attributes)
@subject = subject
@attributes = attributes
end
def fabricate!
presenter_class.new(subject, attributes)
end
private
attr_reader :subject, :attributes
def presenter_class
attributes.delete(:presenter_class) { "#{subject.class.name}Presenter".constantize }
end
end
end
end
end