Class: Belong

Inherits:
Object
  • Object
show all
Defined in:
lib/depend_lister/belong.rb

Instance Method Summary collapse

Instance Method Details

#make_table_belongs_hashObject

Generates the hash(key: table name, value: belongs_to point table name).



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/depend_lister/belong.rb', line 3

def make_table_belongs_hash
  # Generates the hash(key: table name, value: model).
  table_model_hash = to_table_model_hash

  all_tables = table_model_hash.keys
  belogs = {}
  table_model_hash.each do |table, model|
  next unless model
    # the model which does not exist is ignored.
    tables = belong_tables(model)
    # models of alias are exclusion.
    belogs[table] = tables & all_tables
  end
  belogs
end