class TableSaw::ForeignKey::Column

Constants

REGEX

Attributes

value[R]

Public Class Methods

new(value) click to toggle source
# File lib/table_saw/foreign_key.rb, line 10
def initialize(value)
  @value = value
end

Public Instance Methods

primary_key() click to toggle source
# File lib/table_saw/foreign_key.rb, line 14
def primary_key
  value[REGEX, 1]
end
type_condition() click to toggle source
# File lib/table_saw/foreign_key.rb, line 18
def type_condition
  polymorphic? ? "#{type_column} = '#{type_value}'" : '1 = 1'
end

Private Instance Methods

polymorphic?() click to toggle source
# File lib/table_saw/foreign_key.rb, line 32
def polymorphic?
  !(type_column.nil? || type_value.nil?)
end
type_column() click to toggle source
# File lib/table_saw/foreign_key.rb, line 24
def type_column
  value[REGEX, 2]
end
type_value() click to toggle source
# File lib/table_saw/foreign_key.rb, line 28
def type_value
  value[REGEX, 3]
end