
Developers coming from Perl or Php often bring conventions from those languages into Ruby. One important thing I like to tell new Ruby developers is that classes in Ruby are cheap so use them liberally. Ruby is an Object Oriented language and objects are the best way to communicate your intent to future developers reading your code. Let’s look at examples of where a class is more appropriate.
First, we have a method returning multiple values for status.
class ExternalOrderService
def handle_order(order_status)
# stuff here
if order_status.include?('Fail on Shipment')
message = 'Order Failed because of Shipment'
success = false
elsif order_status.include?('Order Processed')
message = 'Order Failed because of Shipment'
success = false
else
message = 'Order Failed for unknown reason'
success = false
end
[message, success]
end
end






