Class: ActiveRecordAutoValidations::OnLoad

Inherits:
Object
  • Object
show all
Defined in:
app/services/active_record_auto_validations/on_load.rb

Class Method Summary collapse

Class Method Details

.execute!(klass:) ⇒ Object



2
3
4
5
6
7
8
# File 'app/services/active_record_auto_validations/on_load.rb', line 2

def self.execute!(klass:)
  # This callback is going to be called for all classes. We should only run auto-validations on the ones that have had the module included
  # which is done through the marked-variable.
  marked = klass.instance_variable_get(:@active_record_auto_validations_marked)

  ActiveRecordAutoValidations::AutoValidateModelClass.execute!(model_class: klass) if marked
end