I am trying to make a rake task but after completion my code i realized i need some refactorization. How could I do refactorization of the following code?
def self.transaction_type(row)
if row['SENDER_BLZ'] == '00000000' and row['RECEIVER_BLZ'] == '00000000'
return 'AccountTransfer'
elsif row['SENDER_BLZ'] == '00000000' and row['UMSATZ_KEY'] == '10'
return 'BankTransfer'
elsif row['RECEIVER_BLZ'] == '70022200' and ['16'].include?row['UMSATZ_KEY']
return 'Lastschrift'
else
return false
end
end
and second method is
def self.import_file_row_with_error_handling(row, validation_only, errors, dtaus)
error_text = nil
self.import_retry_count = 0
5.times do
self.import_retry_count += 1
error_text = nil
begin
import_file_row(row, validation_only, errors, dtaus)
break
rescue => e
error_text = "#{row['ACTIVITY_ID']}: #{e.to_s}"
break
end
end
errors << error_text if error_text
[errors, dtaus]
end
Just need bit guid. thanks