Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Refactor to fewer 'if' statements.

  • Loading branch information...
commit 2dde9ed72e39cfe6bb31fe40f730b285003642d4 1 parent e775167
Gabe Berke-Williams gabebw authored
Showing with 11 additions and 13 deletions.
  1. +11 −13 lib/fake_braintree/customer.rb
24 lib/fake_braintree/customer.rb
View
@@ -42,22 +42,20 @@ def customer_hash
hash = @customer_hash.dup
hash["id"] ||= create_id
- if hash["credit_card"] && hash["credit_card"].is_a?(Hash)
- if !hash["credit_card"].empty?
- hash["credit_card"]["last_4"] = last_four(hash)
- hash["credit_card"]["token"] = credit_card_token(hash)
+ if hash["credit_card"].present? && hash["credit_card"].is_a?(Hash)
+ hash["credit_card"]["last_4"] = last_four(hash)
+ hash["credit_card"]["token"] = credit_card_token(hash)
- if credit_card_expiration_month
- hash["credit_card"]["expiration_month"] = credit_card_expiration_month
- end
-
- if credit_card_expiration_year
- hash["credit_card"]["expiration_year"] = credit_card_expiration_year
- end
+ if credit_card_expiration_month
+ hash["credit_card"]["expiration_month"] = credit_card_expiration_month
+ end
- credit_card = hash.delete("credit_card")
- hash["credit_cards"] = [credit_card]
+ if credit_card_expiration_year
+ hash["credit_card"]["expiration_year"] = credit_card_expiration_year
end
+
+ credit_card = hash.delete("credit_card")
+ hash["credit_cards"] = [credit_card]
else
hash["credit_cards"] = []
end
Please sign in to comment.
Something went wrong with that request. Please try again.