Created
April 17, 2014 22:05
-
-
Save thatrubylove/11014192 to your computer and use it in GitHub Desktop.
an-exercise-in-refactoring-large-methods-in-ruby-example-2
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
def update | |
render if params[:credit_card] | |
process_order(params) | |
else | |
create_shipping_contact(params) | |
end | |
end | |
def process_order(params) | |
response = @order.process(params) | |
if response[:status] == "success" | |
{ :template => "orders/show" } | |
else | |
{ :json => response } | |
end | |
end | |
def create_shipping_contact(params) | |
if params[:shipping_contact].size > 0 && | |
params[:shipping_address].size > 0 | |
@order.create_shipping_contact(params[:shipping_contact], | |
params[:shipping_address]) | |
end | |
{ :template => "orders/show" } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment