Method: ActiveModel::Validations::SinValidatorCanada#initialize

Defined in:
lib/active_validators/active_model/validations/sin_validator.rb

#initialize(str_value, options) ⇒ SinValidatorCanada

Returns a new instance of SinValidatorCanada.



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/active_validators/active_model/validations/sin_validator.rb', line 33

def initialize(str_value, options)
  @sin = str_value.gsub(/\D/, '') # keep only integers
  @allow_permanent_residents = false
  @allow_business_numbers = false

  country_options = options.fetch(:country_options, {})
  allow_permanent_residents = country_options.fetch(:allow_permanent_residents, :nil)
  allow_business_numbers = country_options.fetch(:allow_business_numbers, :nil)

  @allow_permanent_residents = true if allow_permanent_residents == true
  @allow_business_numbers = true if allow_business_numbers == true
end