Class: ActiveSchema::Validations::Generator

Inherits:
Object
  • Object
show all
Defined in:
lib/active_schema/validations/generator.rb

Instance Method Summary collapse

Constructor Details

#initialize(table, skip_validation_for_column) ⇒ Generator

Returns a new instance of Generator.



19
20
21
22
23
# File 'lib/active_schema/validations/generator.rb', line 19

def initialize(table, skip_validation_for_column)
  @table = table
  @model = table.model
  @skip_validation_for_column = skip_validation_for_column
end

Instance Method Details

#generateObject



25
26
27
28
# File 'lib/active_schema/validations/generator.rb', line 25

def generate
  generate_for_columns
  generate_for_indexes
end

#generate_for_columnsObject



30
31
32
33
34
35
36
# File 'lib/active_schema/validations/generator.rb', line 30

def generate_for_columns
  @model.columns.each do |column|
    next if @skip_validation_for_column.call(column)
    ByDataType.new(@model, column).generate
    ByNullability.new(@model, column).generate
  end
end

#generate_for_indexesObject



38
39
40
# File 'lib/active_schema/validations/generator.rb', line 38

def generate_for_indexes
  
end