mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Use guard clauses where possible
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user