Class: Gitlab::Ci::Status::Factory
- Inherits:
-
Object
- Object
- Gitlab::Ci::Status::Factory
show all
- Defined in:
- lib/gitlab/ci/status/factory.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(subject, user) ⇒ Factory
Returns a new instance of Factory.
7
8
9
10
11
|
# File 'lib/gitlab/ci/status/factory.rb', line 7
def initialize(subject, user)
@subject = subject
@user = user
@status = subject.status || ::Ci::HasStatus::DEFAULT_STATUS
end
|
Class Method Details
.common_helpers ⇒ Object
46
47
48
|
# File 'lib/gitlab/ci/status/factory.rb', line 46
def self.common_helpers
Module.new
end
|
.extended_statuses ⇒ Object
42
43
44
|
# File 'lib/gitlab/ci/status/factory.rb', line 42
def self.extended_statuses
[]
end
|
Instance Method Details
#compound_extended_status ⇒ Object
28
29
30
31
32
|
# File 'lib/gitlab/ci/status/factory.rb', line 28
def compound_extended_status
extended_statuses.inject(core_status) do |status, extended|
extended.new(status)
end
end
|
#core_status ⇒ Object
21
22
23
24
25
26
|
# File 'lib/gitlab/ci/status/factory.rb', line 21
def core_status
Gitlab::Ci::Status
.const_get(@status.to_s.camelize, false)
.new(@subject, @user)
.extend(self.class.common_helpers)
end
|
#extended_statuses ⇒ Object
34
35
36
37
38
39
40
|
# File 'lib/gitlab/ci/status/factory.rb', line 34
def extended_statuses
return @extended_statuses if defined?(@extended_statuses)
@extended_statuses = self.class.extended_statuses.flat_map do |group|
Array(group).find { |status| status.matches?(@subject, @user) }
end.compact
end
|
#fabricate! ⇒ Object
13
14
15
16
17
18
19
|
# File 'lib/gitlab/ci/status/factory.rb', line 13
def fabricate!
if extended_statuses.none?
core_status
else
compound_extended_status
end
end
|