Skip to content

Instantly share code, notes, and snippets.

@Sihui
Last active August 3, 2017 05:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sihui/dc1f9f217383db9ac7083a19b639e6b1 to your computer and use it in GitHub Desktop.
Save Sihui/dc1f9f217383db9ac7083a19b639e6b1 to your computer and use it in GitHub Desktop.
Design Pattern: Facade and 1-Click Ordering
class CheckoutProcess
attr_reader :order
def initialize(order)
@order = order
end
def set_shipping_address(address)
order.shipping_address = address
end
def set_payment_method(payment_method)
order.payment_method = payment_method
end
def review_order
puts "Order contains: #{order.items}"
puts "Shipping Address is #{order.shipping_address}"
puts "Payment Method is #{order.payment_method}"
end
def place_order
order.confirm
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment