Class: TableSaw::ForeignKey

Inherits:
Object
  • Object
show all
Defined in:
lib/table_saw/foreign_key.rb

Defined Under Namespace

Classes: Column

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(from_table:, from_column:, to_table:, to_column:, name: nil) ⇒ ForeignKey

Returns a new instance of ForeignKey.



39
40
41
42
43
44
45
# File 'lib/table_saw/foreign_key.rb', line 39

def initialize(from_table:, from_column:, to_table:, to_column:, name: nil)
  @name = name
  @from_table = from_table
  @from_column = from_column
  @to_table = to_table
  @to_column = to_column
end

Instance Attribute Details

#from_columnObject (readonly)

Returns the value of attribute from_column.



37
38
39
# File 'lib/table_saw/foreign_key.rb', line 37

def from_column
  @from_column
end

#from_tableObject (readonly)

Returns the value of attribute from_table.



37
38
39
# File 'lib/table_saw/foreign_key.rb', line 37

def from_table
  @from_table
end

#nameObject (readonly)

Returns the value of attribute name.



37
38
39
# File 'lib/table_saw/foreign_key.rb', line 37

def name
  @name
end

#to_columnObject (readonly)

Returns the value of attribute to_column.



37
38
39
# File 'lib/table_saw/foreign_key.rb', line 37

def to_column
  @to_column
end

#to_tableObject (readonly)

Returns the value of attribute to_table.



37
38
39
# File 'lib/table_saw/foreign_key.rb', line 37

def to_table
  @to_table
end

Instance Method Details

#columnObject



51
52
53
# File 'lib/table_saw/foreign_key.rb', line 51

def column
  @column ||= Column.new(from_column)
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/table_saw/foreign_key.rb', line 55

def eql?(other)
  hash == other.hash
end

#hashObject



59
60
61
# File 'lib/table_saw/foreign_key.rb', line 59

def hash
  [from_table, from_column, to_table, to_column].hash
end

#type_conditionObject



47
48
49
# File 'lib/table_saw/foreign_key.rb', line 47

def type_condition
  @type_condition ||= column.type_condition
end