Class: DbValidator::Validator

Inherits:
Object
  • Object
show all
Defined in:
lib/db_validator/validator.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Validator

Returns a new instance of Validator.



8
9
10
11
12
# File 'lib/db_validator/validator.rb', line 8

def initialize(options = {})
  @options = options
  @reporter = Reporter.new
  @fixer = Fixer.new if DbValidator.configuration.auto_fix
end

Instance Method Details

#validate_allObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/db_validator/validator.rb', line 14

def validate_all
  Rails.application.eager_load! if defined?(Rails)

  models = find_all_models

  models_to_validate = models.select { |model| should_validate_model?(model) }
  total_models = models_to_validate.size

  models_to_validate.each_with_index do |model, index|
    Rails.logger.debug "Validating model #{index + 1}/#{total_models}: #{model.name}".colorize(:cyan)
    validate_model(model)
  end

  @reporter.generate_report
end