Use guard clauses where possible

This commit is contained in:
Rob Harrington
2017-07-07 15:31:18 +10:00
parent a68ae1fe2d
commit ecb78233d9
3 changed files with 10 additions and 11 deletions

View File

@@ -30,9 +30,8 @@ module Spree
# Currently can only destroy the whole customer object
def destroy_at_stripe
if stripe_customer = Stripe::Customer.retrieve( @credit_card.gateway_customer_profile_id )
stripe_customer.delete
end
stripe_customer = Stripe::Customer.retrieve(@credit_card.gateway_customer_profile_id)
stripe_customer.delete if stripe_customer
end
private

View File

@@ -9,9 +9,9 @@ Spree::UsersController.class_eval do
def show
@orders = @user.orders.where(state: 'complete').order('completed_at desc')
if Spree::Config.accounts_distributor_id
@orders = @orders.where('distributor_id != ?', Spree::Config.accounts_distributor_id)
end
return unless Spree::Config.accounts_distributor_id
@orders = @orders.where('distributor_id != ?', Spree::Config.accounts_distributor_id)
end
private

View File

@@ -78,11 +78,11 @@ module Spree
# Import from future Spree
def build_source
return if source_attributes.nil?
if payment_method && payment_method.payment_source_class
self.source = payment_method.payment_source_class.new(source_attributes)
source.payment_method_id = payment_method.id
source.user_id = order.user_id if order
end
return unless payment_method.andand.payment_source_class
self.source = payment_method.payment_source_class.new(source_attributes)
source.payment_method_id = payment_method.id
source.user_id = order.user_id if order
end
private