Permalink
Browse files

Refactor confusing 'more_opts' line in create_payment_method

This code was complicated because I was trying to handle the case where someone posts to
create_payment_method without a 'credit_card' param. But that should be an error
anyway, so why handle it?
  • Loading branch information...
1 parent c7f2ba4 commit 90fd206f6946f33441b736eb310ac02049803a26 @wonnage wonnage committed with Gabe Berke-Williams Nov 27, 2012
Showing with 5 additions and 6 deletions.
  1. +5 −6 lib/fake_braintree/redirect.rb
@@ -21,12 +21,11 @@ def confirm
if @kind == 'create_customer'
Customer.new(@params["customer"], {:merchant_id => @merchant_id}).create
elsif @kind == 'create_payment_method'
- options = {:merchant_id => @merchant_id}
- if more_opts = (@transparent_data['credit_card'] && @transparent_data['credit_card'].delete('options'))
- options.merge!(more_opts)
- end
- options.symbolize_keys!
- CreditCard.new(@params['credit_card'].merge(@transparent_data['credit_card']), options).create
+ credit_card_options = {:merchant_id => @merchant_id}
+ credit_card_options.merge!(@transparent_data['credit_card'].fetch('options', {}))
+
+ credit_card_options.symbolize_keys!
+ CreditCard.new(@params['credit_card'].merge(@transparent_data['credit_card']), credit_card_options).create
end
end

0 comments on commit 90fd206

Please sign in to comment.