Off the top of my head, here’s an example of a status object.
# Some handy constants to give meaning to some booleans we'll be using
SUCCESS = true
FAILURE = false
# A factory method to easily create a status that represents success
# A factory method to easily create a status that represents failure
def initialize(success, message=nil)
@success = success
@message = message
The method users of this class would call to check if a status represents success
@success == SUCCESS
If the method you were talking about, rather than returning nil for success and a string with the failure message for failures, return either
CommandStatus.failure(your_failure_message) on failures.
The code that uses receives this status object returned to it, would do something like:
# handle success