Class: HCA::OverridesParser
- Inherits:
-
Object
- Object
- HCA::OverridesParser
- Defined in:
- app/services/hca/overrides_parser.rb
Constant Summary collapse
- STATE_OVERRIDES =
{ 'MEX' => { 'aguascalientes' => 'AGS.', 'baja-california-norte' => 'B.C.', 'baja-california-sur' => 'B.C.S.', 'campeche' => 'CAM.', 'chiapas' => 'CHIS.', 'chihuahua' => 'CHIH.', 'coahuila' => 'COAH.', 'colima' => 'COL.', 'distrito-federal' => 'D.F.', 'durango' => 'DGO.', 'guanajuato' => 'GTO.', 'guerrero' => 'GRO.', 'hidalgo' => 'HGO.', 'jalisco' => 'JAL.', 'mexico' => 'MEX.', 'michoacan' => 'MICH.', 'morelos' => 'MOR.', 'nayarit' => 'NAY.', 'nuevo-leon' => 'N.L.', 'oaxaca' => 'OAX.', 'puebla' => 'PUE.', 'queretaro' => 'QRO.', 'quintana-roo' => 'Q.ROO.', 'san-luis-potosi' => 'S.L.P.', 'sinaloa' => 'SIN.', 'sonora' => 'SON.', 'tabasco' => 'TAB.', 'tamaulipas' => 'TAMPS.', 'tlaxcala' => 'TLAX.', 'veracruz' => 'VER.', 'yucatan' => 'YUC.', 'zacatecas' => 'ZAC.' } }.freeze
Instance Attribute Summary collapse
-
#form ⇒ Object
Returns the value of attribute form.
-
#params ⇒ Object
Returns the value of attribute params.
Instance Method Summary collapse
-
#initialize(form) ⇒ OverridesParser
constructor
A new instance of OverridesParser.
- #override ⇒ Object
- #override_address_states ⇒ Object
- #override_individual_address(key) ⇒ Object
Constructor Details
#initialize(form) ⇒ OverridesParser
Returns a new instance of OverridesParser.
44 45 46 |
# File 'app/services/hca/overrides_parser.rb', line 44 def initialize(form) @form = form end |
Instance Attribute Details
#form ⇒ Object
Returns the value of attribute form.
42 43 44 |
# File 'app/services/hca/overrides_parser.rb', line 42 def form @form end |
#params ⇒ Object
Returns the value of attribute params.
42 43 44 |
# File 'app/services/hca/overrides_parser.rb', line 42 def params @params end |
Instance Method Details
#override ⇒ Object
48 49 50 51 52 |
# File 'app/services/hca/overrides_parser.rb', line 48 def override override_address_states form end |
#override_address_states ⇒ Object
54 55 56 57 58 |
# File 'app/services/hca/overrides_parser.rb', line 54 def override_address_states %w[veteranHomeAddress veteranAddress spouseAddress].each do |target| override_individual_address(target) end end |
#override_individual_address(key) ⇒ Object
60 61 62 63 64 65 66 67 68 |
# File 'app/services/hca/overrides_parser.rb', line 60 def override_individual_address(key) country = form.dig(key, 'country') state = form.dig(key, 'state') return unless STATE_OVERRIDES.key?(country) return unless STATE_OVERRIDES[country]&.key?(state) form[key]['state'] = STATE_OVERRIDES[country][state] end |