BigW Consortium Gitlab

factory.rb 462 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10
module Gitlab
  module View
    module Presenter
      class Factory
        def initialize(subject, **attributes)
          @subject = subject
          @attributes = attributes
        end

        def fabricate!
11
          presenter_class.new(subject, attributes)
12 13 14 15
        end

        private

16 17
        attr_reader :subject, :attributes

18
        def presenter_class
19
          "#{subject.class.name}Presenter".constantize
20 21 22 23 24
        end
      end
    end
  end
end