debian-mirror-gitlab/lib/gitlab/merge_requests/mergeability/check_result.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

49 lines
1.1 KiB
Ruby
Raw Normal View History

2021-11-18 22:05:49 +05:30
# frozen_string_literal: true
module Gitlab
module MergeRequests
module Mergeability
class CheckResult
SUCCESS_STATUS = :success
FAILED_STATUS = :failed
attr_reader :status, :payload
def self.default_payload
{ last_run_at: Time.current }
end
def self.success(payload: {})
new(status: SUCCESS_STATUS, payload: default_payload.merge(payload))
end
def self.failed(payload: {})
new(status: FAILED_STATUS, payload: default_payload.merge(payload))
end
def self.from_hash(data)
new(
2022-05-07 20:08:51 +05:30
status: data.fetch('status').to_sym,
payload: data.fetch('payload'))
2021-11-18 22:05:49 +05:30
end
def initialize(status:, payload: {})
@status = status
@payload = payload
end
def to_hash
{ status: status, payload: payload }
end
def failed?
status == FAILED_STATUS
end
def success?
status == SUCCESS_STATUS
end
end
end
end
end