Class: Sortiri::ActiveRecord::ForeignColumn

Inherits:
Column
  • Object
show all
Defined in:
lib/sortiri/active_record/foreign_column.rb

Instance Attribute Summary

Attributes inherited from Column

#association_name, #name

Instance Method Summary collapse

Methods inherited from Column

#matches_with?, #name_with_table_name

Constructor Details

#initialize(name:, model:, association_name:) ⇒ ForeignColumn

Returns a new instance of ForeignColumn.



6
7
8
# File 'lib/sortiri/active_record/foreign_column.rb', line 6

def initialize(name:, model:, association_name:)
  super(name: name, model: model, association_name: association_name)
end

Instance Method Details

#foreign_keyObject



10
11
12
# File 'lib/sortiri/active_record/foreign_column.rb', line 10

def foreign_key
  @model.reflect_on_association(association_name).foreign_key
end

#table_nameObject



14
15
16
# File 'lib/sortiri/active_record/foreign_column.rb', line 14

def table_name
  @model.reflect_on_association(association_name).table_name
end