Class: ActiveSchema::Associations::Generator

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

Instance Method Summary collapse

Constructor Details

#initialize(from_table, to_table, column_name) ⇒ Generator

Returns a new instance of Generator.



7
8
9
10
11
# File 'lib/active_schema/associations/generator.rb', line 7

def initialize(from_table, to_table, column_name)
  @from_table   = from_table
  @to_table     = to_table
  @column_name  = column_name
end

Instance Method Details

#generateObject



13
14
15
16
17
18
19
20
21
# File 'lib/active_schema/associations/generator.rb', line 13

def generate
  [ByForwardForeignKey, ByReverseForeignKey].each do |generators|
    generators.new(@from_table.model,
      @to_table.model,
      @column_name,
      @from_table.unique_index_on?(@column_name)).generate
    
  end
end