Class: Gitlab::MergeRequests::Mergeability::CheckResult
- Inherits:
-
Object
- Object
- Gitlab::MergeRequests::Mergeability::CheckResult
- Defined in:
- lib/gitlab/merge_requests/mergeability/check_result.rb
Constant Summary collapse
- SUCCESS_STATUS =
:success
- FAILED_STATUS =
:failed
- INACTIVE_STATUS =
:inactive
- WARNING_STATUS =
:warning
- CHECKING_STATUS =
:checking
Instance Attribute Summary collapse
-
#payload ⇒ Object
readonly
Returns the value of attribute payload.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Class Method Summary collapse
- .checking(payload: {}) ⇒ Object
- .default_payload ⇒ Object
- .failed(payload: {}) ⇒ Object
- .from_hash(data) ⇒ Object
- .inactive(payload: {}) ⇒ Object
- .success(payload: {}) ⇒ Object
- .warning(payload: {}) ⇒ Object
Instance Method Summary collapse
- #checking? ⇒ Boolean
- #failed? ⇒ Boolean
- #identifier ⇒ Object
-
#initialize(status:, payload: {}) ⇒ CheckResult
constructor
A new instance of CheckResult.
- #success? ⇒ Boolean
- #to_hash ⇒ Object
- #unsuccessful? ⇒ Boolean
Constructor Details
#initialize(status:, payload: {}) ⇒ CheckResult
Returns a new instance of CheckResult.
44 45 46 47 |
# File 'lib/gitlab/merge_requests/mergeability/check_result.rb', line 44 def initialize(status:, payload: {}) @status = status @payload = payload end |
Instance Attribute Details
#payload ⇒ Object (readonly)
Returns the value of attribute payload.
12 13 14 |
# File 'lib/gitlab/merge_requests/mergeability/check_result.rb', line 12 def payload @payload end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
12 13 14 |
# File 'lib/gitlab/merge_requests/mergeability/check_result.rb', line 12 def status @status end |
Class Method Details
.checking(payload: {}) ⇒ Object
26 27 28 |
# File 'lib/gitlab/merge_requests/mergeability/check_result.rb', line 26 def self.checking(payload: {}) new(status: CHECKING_STATUS, payload: default_payload.merge(**payload)) end |
.default_payload ⇒ Object
14 15 16 |
# File 'lib/gitlab/merge_requests/mergeability/check_result.rb', line 14 def self.default_payload { last_run_at: Time.current } end |
.failed(payload: {}) ⇒ Object
22 23 24 |
# File 'lib/gitlab/merge_requests/mergeability/check_result.rb', line 22 def self.failed(payload: {}) new(status: FAILED_STATUS, payload: default_payload.merge(**payload)) end |
.from_hash(data) ⇒ Object
38 39 40 41 42 |
# File 'lib/gitlab/merge_requests/mergeability/check_result.rb', line 38 def self.from_hash(data) new( status: data.fetch(:status).to_sym, payload: data.fetch(:payload)) end |
.inactive(payload: {}) ⇒ Object
30 31 32 |
# File 'lib/gitlab/merge_requests/mergeability/check_result.rb', line 30 def self.inactive(payload: {}) new(status: INACTIVE_STATUS, payload: default_payload.merge(**payload)) end |
.success(payload: {}) ⇒ Object
18 19 20 |
# File 'lib/gitlab/merge_requests/mergeability/check_result.rb', line 18 def self.success(payload: {}) new(status: SUCCESS_STATUS, payload: default_payload.merge(**payload)) end |
.warning(payload: {}) ⇒ Object
34 35 36 |
# File 'lib/gitlab/merge_requests/mergeability/check_result.rb', line 34 def self.warning(payload: {}) new(status: WARNING_STATUS, payload: default_payload.merge(**payload)) end |
Instance Method Details
#checking? ⇒ Boolean
65 66 67 |
# File 'lib/gitlab/merge_requests/mergeability/check_result.rb', line 65 def checking? status == CHECKING_STATUS end |
#failed? ⇒ Boolean
57 58 59 |
# File 'lib/gitlab/merge_requests/mergeability/check_result.rb', line 57 def failed? status == FAILED_STATUS end |
#identifier ⇒ Object
53 54 55 |
# File 'lib/gitlab/merge_requests/mergeability/check_result.rb', line 53 def identifier payload&.fetch(:identifier)&.to_sym end |
#success? ⇒ Boolean
61 62 63 |
# File 'lib/gitlab/merge_requests/mergeability/check_result.rb', line 61 def success? status == SUCCESS_STATUS end |
#to_hash ⇒ Object
49 50 51 |
# File 'lib/gitlab/merge_requests/mergeability/check_result.rb', line 49 def to_hash { status: status, payload: payload } end |
#unsuccessful? ⇒ Boolean
69 70 71 |
# File 'lib/gitlab/merge_requests/mergeability/check_result.rb', line 69 def unsuccessful? failed? || checking? end |