Permalink
Browse files

Less direct access of ivar.

  • Loading branch information...
1 parent 3c66129 commit d2f470e82f3499b5260e0e00bed62f763b1773d5 Gabe Berke-Williams committed Jan 13, 2012
Showing with 8 additions and 3 deletions.
  1. +8 −3 lib/fake_braintree/customer.rb
@@ -7,6 +7,8 @@ def initialize(customer_hash_from_params, options)
"id" => options[:id],
"merchant_id" => options[:merchant_id]
}.merge(customer_hash_from_params)
+
+ set_customer_id
end
def create
@@ -57,7 +59,6 @@ def update_customer!(updates_hash)
def customer_hash
hash = @customer_hash.dup
- hash["id"] ||= create_id(@merchant_id)
hash["credit_cards"] = generate_credit_cards_from(hash["credit_card"])
hash
@@ -76,7 +77,7 @@ def credit_card_is_failure?
end
def invalid_credit_card?
- verify_credit_card?(@customer_hash) && has_invalid_credit_card?(@customer_hash)
+ verify_credit_card?(customer_hash) && has_invalid_credit_card?(customer_hash)
end
def verify_credit_card?(customer_hash_for_verification)
@@ -163,7 +164,7 @@ def failure_response(code)
end
def customer_id
- @customer_hash["id"]
+ customer_hash["id"]
end
def has_credit_card?
@@ -174,6 +175,10 @@ def credit_card_hash
@customer_hash["credit_card"] || {}
end
+ def set_customer_id
+ @customer_hash["id"] ||= create_id(@customer_hash["merchant_id"])
+ end
+
def credit_card_token(credit_card_hash_without_token)
md5("#{credit_card_hash_without_token["number"]}#{@customer_hash['merchant_id']}")
end

0 comments on commit d2f470e

Please sign in to comment.