Skip to content

Commit

Permalink
Refactor customer deletion logic to use customer.balance.zero? instea…
Browse files Browse the repository at this point in the history
…d of balance? method
  • Loading branch information
fabianoflorentino committed Mar 25, 2024
1 parent eef1176 commit b27d5c6
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions app/use_cases/customer_use_case/delete.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def initialize(id)
end

def call
return customer.destroy! if balance?
return customer.destroy! if customer.balance.zero?

raise SharedErrors::BalanceEmpty
end
Expand All @@ -18,11 +18,7 @@ def call
attr_reader :id

def customer
@customer = Customer.includes(:transactions).find(@id)
end

def balance?
customer.balance.zero?
Customer.includes(:transactions).find(@id)
end
end
end

0 comments on commit b27d5c6

Please sign in to comment.