From 319b27a5d19e64a46fb2479c9265603d7007dcf0 Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Tue, 18 Jan 2022 10:20:38 -0500 Subject: [PATCH] Use default from Customer constructor --- lib/customer_repo.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/customer_repo.rb b/lib/customer_repo.rb index 573dbd7c473a25b8c11732a5a929cb28401ffba4..4358b672d4584b985431632c92f9e49526daa257 100644 --- a/lib/customer_repo.rb +++ b/lib/customer_repo.rb @@ -101,7 +101,7 @@ protected def fetch_sql(customer_id) @db.query_defer(SQL, [customer_id]).then do |rows| - rows.first&.transform_keys(&:to_sym) || { balance: 0 } + rows.first&.transform_keys(&:to_sym) || {} end end @@ -123,11 +123,11 @@ protected fetch_all(customer_id).then do |(sgx, data)| Customer.new( customer_id, Blather::JID.new(jid), - sgx: sgx, balance: data[:balance], tndetails: tndetails(sgx), + sgx: sgx, tndetails: tndetails(sgx), plan: CustomerPlan.for( customer_id, - **data.delete_if { |(k, _)| k == :balance } - ) + **data.reject { |(k, _)| k == :balance } + ), **data.slice(:balance) ) end end