I'm writing code for a worker receiving message from a queue.It should send an emailsave the fact that this email has been sentacknowledge the joblog some info.I wrote the following code, but I find it ugly!Do you have some advice on how to refactor it ?class MailWorker  def initialize(logger, db, smtp)      @logger = logger      @db = db      @smtp = smtp  end  def handle(message)    start = Time.now.utc.to_f    data = JSON.parse(message.body, symbolize_names: true)    smtp_resp = send(data)    save_as_sent(data[:id], smtp_resp['request_id'])    message.delete    @logger.info(Mail send #{data[:id]} start:#{start} spent:#{(Time.now.utc.to_f - start)})  rescue Aws::SQS::Errors::ServiceError, Smtp::Error => e    @logger.error(Mail error for mail #{data[:id]} #{e.backtrace.join(\n)})  end  private  def send(data)    @smtp.send(data[:to], data[:subject], data[:body])  end  def save_as_sent(id, request_id)    @db.prepare('UPDATE Mail set request_id = ? WHERE id = ?')    @db.execute(request_id, id)  endend
Send email from job queue, save status, acknowledge and log info
ruby