Skip to content

Instantly share code, notes, and snippets.

@StevenJL
Last active November 26, 2018 07:23
Show Gist options
  • Save StevenJL/fd54686c8aa66e343e15b77f9b842e8e to your computer and use it in GitHub Desktop.
Save StevenJL/fd54686c8aa66e343e15b77f9b842e8e to your computer and use it in GitHub Desktop.
class CompleteOrder
def perform
notify_recipient(order.recipient)
update_inventory(order.item_number)
prepare_shippping(order.shipping_address)
end
private
def order
# cache the query for order as an instance variable
# since it is accessed multiple times in the #perform method
@order ||= Order.find_by(id: @order_id)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment