Module: Datagaze::Models

Defined in:
lib/datagaze/models/models/base.rb,
lib/datagaze/models/models/fixed_text_elements.rb,
lib/datagaze/models/models/get_all_model_constants.rb,
lib/datagaze/models/models/print_schema_information.rb

Constant Summary collapse

ColumnPadding =
5

Class Method Summary collapse

Class Method Details

.annotate_all_modelsObject

The method that creates all annotations



5
6
7
8
9
# File 'lib/datagaze/models/models/base.rb', line 5

def annotate_all_models
  collect_all_models.each do |model, atts|
    annotate_one_model(model: model, **atts.slice(:path, :table_name) )
  end
end

.clean_all_annotationsObject

The method that removes all annotations, if desired



12
13
14
15
16
# File 'lib/datagaze/models/models/base.rb', line 12

def clean_all_annotations
  collect_all_models.each do |model, atts|
    clean_one_model(model: model, **atts.slice(:path) )
  end
end

.collect_all_modelsObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/datagaze/models/models/get_all_model_constants.rb', line 4

def collect_all_models     
  
  models = ApplicationRecord.descendants.select { |model| !model.abstract_class? }
  
  models.map do |model|
   
    path, line_no = ApplicationRecord.const_source_location(model.to_s)
    table_name    = model.table_name
    
    { model => { path: path, table_name: table_name } }

  end.reduce(&:merge)

end