gitlab-org--gitlab-foss/lib/gitlab/ci/status/factory.rb

48 lines
963 B
Ruby
Raw Normal View History

2016-12-07 07:14:45 -05:00
module Gitlab
module Ci
module Status
class Factory
def initialize(subject, user)
2016-12-07 07:14:45 -05:00
@subject = subject
@user = user
2016-12-07 07:14:45 -05:00
end
def fabricate!
if extended_status
extended_status.new(core_status)
else
core_status
end
end
def self.extended_statuses
[]
end
def self.common_helpers
Module.new
end
2016-12-07 07:14:45 -05:00
private
def simple_status
@simple_status ||= @subject.status || :created
2016-12-07 07:14:45 -05:00
end
def core_status
Gitlab::Ci::Status
.const_get(simple_status.capitalize)
.new(@subject, @user)
.extend(self.class.common_helpers)
2016-12-07 07:14:45 -05:00
end
def extended_status
@extended ||= self.class.extended_statuses.find do |status|
status.matches?(@subject, @user)
2016-12-07 07:14:45 -05:00
end
end
end
end
end
end