Skip to content

Instantly share code, notes, and snippets.

@BrandonMathis
Created May 23, 2019 14:47
Show Gist options
  • Select an option

  • Save BrandonMathis/fabcf0f26fdeb38e3fef1e2808f59e45 to your computer and use it in GitHub Desktop.

Select an option

Save BrandonMathis/fabcf0f26fdeb38e3fef1e2808f59e45 to your computer and use it in GitHub Desktop.
class Order::PurchaseService
attr_accessor :cart, :user, :credit_card
def initialize(cart, user, credit_card)
@cart = cart
@user = user
@credit_card = credit_card
end
def perform
transform_cart_into_order(@cart)
calculate_tax!
calculate_shipping!
charge_credit_card
send_order_request_to_warehouse!
email_invoice_to_user(current_user)!
end
...
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment