Class: ActiveSanity::Checker
- Inherits:
-
Object
- Object
- ActiveSanity::Checker
- Defined in:
- lib/active_sanity/checker.rb
Class Attribute Summary collapse
-
.batch_size ⇒ Object
Returns the value of attribute batch_size.
Class Method Summary collapse
Instance Method Summary collapse
- #check! ⇒ Object
-
#initialize ⇒ Checker
constructor
A new instance of Checker.
-
#models ⇒ Array
Of [ActiveRecord::Base] direct descendants.
Constructor Details
#initialize ⇒ Checker
Returns a new instance of Checker.
7 8 9 |
# File 'lib/active_sanity/checker.rb', line 7 def initialize Checker.batch_size ||= 500 end |
Class Attribute Details
.batch_size ⇒ Object
Returns the value of attribute batch_size.
4 5 6 |
# File 'lib/active_sanity/checker.rb', line 4 def batch_size @batch_size end |
Class Method Details
.check! ⇒ Object
11 12 13 |
# File 'lib/active_sanity/checker.rb', line 11 def self.check! new.check! end |
Instance Method Details
#check! ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/active_sanity/checker.rb', line 15 def check! puts 'Sanity Check' puts "Checking the following models: #{models.join(', ')}" # TODO: Wouldnt this list already be checked by the next all records call if those records do exist? # This will validate and destroy the records that either dont exist currently, or are now valid. But the ones are continue to be invalid - these will # have been run through the validation process twice check_previously_invalid_records check_all_records end |
#models ⇒ Array
Returns of [ActiveRecord::Base] direct descendants.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/active_sanity/checker.rb', line 27 def models return @models if @models load_all_models @models ||= direct_active_record_base_descendants @models -= [InvalidRecord] if File.exist?('active_sanity.ignore.yml') yaml_contents = YAML.load_file('active_sanity.ignore.yml') model_names_to_ignore = Array(yaml_contents['models'] || []).uniq @models = @models.reject { |model| model_names_to_ignore.include?(model.name) } end @models end |