class SeaFood::Service::ServiceResult

def failed?

Returns:
  • (Boolean) - True if failed, false otherwise.
def failed?
  !success
end

def initialize(success: true, data: nil, errors: nil)

Parameters:
  • data (Any) -- The data returned by the service.
  • success (Boolean) -- Indicates if the service call was successful.
def initialize(success: true, data: nil, errors: nil)
  @success = success
  @data = (data || {}).with_indifferent_access
  @errors = (errors.to_h || {}).with_indifferent_access
end

def method_missing(key)

:rubocop:disable Style/MissingRespondToMissing
def method_missing(key)
  if succeeded?
    @data[key]
  else
    @errors[key]
  end
end

def succeeded?

Returns:
  • (Boolean) - True if successful, false otherwise.
def succeeded?
  success
end