In an attempt to have smaller methods, I'm moving some parts out of a method into smaller private methods. In one private method, however, I'm doing some error handling and would like to break out of the method that called the private method, not just the private method itself. Really basic example, but:
def public method
private_method
# Do other stuff based on the results of that private method
end
private
def private method
objects = Object.where('something')
return 'No objects' if objects.count == 0
return 'Less than 3 objects' if objects.count < 3
objects
end
How might I break out of the public method entirely and return with those values based on the count, instead of just returning 'No objects' to the public method if that's the case.