Class: BGS::Job
- Inherits:
-
Object
- Object
- BGS::Job
- Includes:
- Utilities::Helpers
- Defined in:
- app/sidekiq/bgs/job.rb
Direct Known Subclasses
SubmitForm674EncryptedJob, SubmitForm674Job, SubmitForm686cEncryptedJob, SubmitForm686cJob
Instance Method Summary collapse
- #in_progress_form_copy(in_progress_form) ⇒ Object
-
#normalize_names_and_addresses!(hash) ⇒ Object
BGS doesn’t accept name and address_line fields with non-ASCII characters (e.g. ü, ñ), and doesn’t accept names with apostrophes.
- #salvage_save_in_progress_form(form_id, user_uuid, copy) ⇒ Object
Methods included from Utilities::Helpers
#normalize_composite_characters, #remove_special_characters_from_name
Instance Method Details
#in_progress_form_copy(in_progress_form) ⇒ Object
9 10 11 12 13 14 15 |
# File 'app/sidekiq/bgs/job.rb', line 9 def in_progress_form_copy(in_progress_form) return nil if in_progress_form.blank? OpenStruct.new(meta_data: in_progress_form., form_data: in_progress_form.form_data, user_account: in_progress_form.user_account) end |
#normalize_names_and_addresses!(hash) ⇒ Object
BGS doesn’t accept name and address_line fields with non-ASCII characters (e.g. ü, ñ), and doesn’t accept names with apostrophes. This method recursively iterates through a given hash and strips unprocessable characters from name and address_line fields. The method is called in ‘SubmitForm686cJob` and `SubmitForm674Job` with an enormous form payload potentially containing many names and addresses. See `spec/factories/686c/form_686c_674.rb` for an example of such a payload.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/sidekiq/bgs/job.rb', line 30 def normalize_names_and_addresses!(hash) hash.each do |key, val| case val when Hash normalize_names_and_addresses!(val) when Array val.each { |v| normalize_names_and_addresses!(v) if v.is_a?(Hash) } else is_name_key = %w[first middle last].include?(key) if val && (is_name_key || key.include?('address_line')) val = normalize_composite_characters(val) val = remove_special_characters_from_name(val) if is_name_key hash[key] = val end end end end |
#salvage_save_in_progress_form(form_id, user_uuid, copy) ⇒ Object
17 18 19 20 21 22 23 |
# File 'app/sidekiq/bgs/job.rb', line 17 def salvage_save_in_progress_form(form_id, user_uuid, copy) return if copy.blank? form = InProgressForm.where(form_id:, user_uuid:).first_or_initialize form.user_account = copy.user_account form.update(form_data: copy.form_data) end |