gitlab-org--gitlab-foss/app/services/service_response.rb
Oswaldo Ferreira 3af348b6cf Automatically update MR merge-ref along merge status
This couples the code that transitions the `MergeRequest#merge_status`
and refs/merge-requests/:iid/merge ref update.

In general, instead of directly telling `MergeToRefService` to update
the merge ref, we should rely on `MergeabilityCheckService` to keep
both the merge status and merge ref synced. Now, if the merge_status is
`can_be_merged` it means the merge-ref is also updated to the latest.

We've also updated the logic to be more systematic and less user-based.
2019-06-20 11:48:30 -03:00

32 lines
725 B
Ruby

# frozen_string_literal: true
class ServiceResponse
def self.success(message: nil, payload: {})
new(status: :success, message: message, payload: payload)
end
def self.error(message:, payload: {}, http_status: nil)
new(status: :error, message: message, payload: payload, http_status: http_status)
end
attr_reader :status, :message, :http_status, :payload
def initialize(status:, message: nil, payload: {}, http_status: nil)
self.status = status
self.message = message
self.payload = payload
self.http_status = http_status
end
def success?
status == :success
end
def error?
status == :error
end
private
attr_writer :status, :message, :http_status, :payload
end