Skip to content
Browse files

Merge pull request #1 from orend/finished

Show changes to depend_upon_abstractions in a commit
  • Loading branch information...
2 parents bf82f0f + 36f985d commit 37fd3bfed608f5b9d03a27f01e8e521ba3ca148c @r00k committed Nov 8, 2012
Showing with 3 additions and 24 deletions.
  1. +3 −7 lib/depend_upon_abstractions.rb
  2. +0 −17 lib/{depend_upon_abstractions_fixed.rb → payment_gateway.rb}
View
10 lib/depend_upon_abstractions.rb
@@ -1,19 +1,15 @@
class User
- SUBSCRIPTION_AMOUNT = 10.to_money
-
def charge_for_subscription
- braintree_id = BraintreeGem.find_user(email).braintree_id
- BraintreeGem.charge(braintree_id, SUBSCRIPTION_AMOUNT)
+ PaymentGateway.new.charge_for_subscription(self)
end
def create_as_customer
- BraintreeGem.create_customer(email)
+ PaymentGateway.new.create_customer(self)
end
end
class Refund
def process!
- transaction_id = BraintreeGem.find_transaction(order.braintree_id)
- BraintreeGem.refund(transaction_id, amount)
+ PaymentGateway.new.refund(self)
end
end
View
17 lib/depend_upon_abstractions_fixed.rb → lib/payment_gateway.rb
@@ -1,20 +1,3 @@
-class User
- def charge_for_subscription
- PaymentGateway.new.charge_for_subscription(self)
- end
-
- def create_as_customer
- PaymentGateway.new.create_customer(self)
- end
-end
-
-class Refund
- def process!
- PaymentGateway.new.refund(self)
- end
-end
-
-# lib/payment_gateway.rb
class PaymentGateway
SUBSCRIPTION_AMOUNT = 10.to_money

0 comments on commit 37fd3bf

Please sign in to comment.
Something went wrong with that request. Please try again.