class ForeignKeyNode

Public Class Methods

new(col, table, *actions) click to toggle source
# File lib/code_generator.rb, line 276
def initialize col, table, *actions
  @col = col
  @table = table
  if actions.count > 0
    @action = actions[0]
  end
end

Public Instance Methods

gen() click to toggle source
# File lib/code_generator.rb, line 284
def gen
  col = @col.gen
  table_name = @table.gen
  class_name = @table.table_to_class
  key = @table.key_name
  "belongs_to :#{table_name}, foreign_key: '#{col}', class: '#{class_name}', primary_key: '#{key}'"
end