Last active
August 3, 2017 05:04
-
-
Save Sihui/dc1f9f217383db9ac7083a19b639e6b1 to your computer and use it in GitHub Desktop.
Design Pattern: Facade and 1-Click Ordering
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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