Class: AssociationReporter::OneToManyAssociationAssumption

Inherits:
AssociationAssumption show all
Defined in:
lib/association-reporter/assumption.rb

Instance Method Summary collapse

Methods inherited from AssociationAssumption

#assoc_klass, #assoc_klass_label, #assoc_klass_name, #assoc_table, #assoc_table_label, #valid_table?

Methods inherited from Assumption

#initialize

Constructor Details

This class inherits a constructor from AssociationReporter::Assumption

Instance Method Details

#fkey_columnObject



106
107
108
# File 'lib/association-reporter/assumption.rb', line 106

def fkey_column
  reflection.foreign_key
end

#fkey_column_labelObject



110
111
112
# File 'lib/association-reporter/assumption.rb', line 110

def fkey_column_label
  labelize(fkey_column, valid_fkey_table? && valid_fkey_column?)
end

#fkey_tableObject



94
95
96
97
98
99
100
# File 'lib/association-reporter/assumption.rb', line 94

def fkey_table
  if reflection.is_a?(ActiveRecord::Reflection::BelongsToReflection)
    table_name = reflection.active_record.table_name
  else
    table_name = assoc_table
  end
end

#fkey_table_labelObject



102
103
104
# File 'lib/association-reporter/assumption.rb', line 102

def fkey_table_label
  labelize(fkey_table, valid_fkey_table?)
end

#valid?Boolean

Returns:

  • (Boolean)


122
123
124
# File 'lib/association-reporter/assumption.rb', line 122

def valid?
  super && valid_fkey_table? && valid_fkey_column?
end

#valid_fkey_column?Boolean

Returns:

  • (Boolean)


118
119
120
# File 'lib/association-reporter/assumption.rb', line 118

def valid_fkey_column?
  ActiveRecord::Base.connection.column_exists?(fkey_table, fkey_column)
end

#valid_fkey_table?Boolean

Returns:

  • (Boolean)


114
115
116
# File 'lib/association-reporter/assumption.rb', line 114

def valid_fkey_table?
  ActiveRecord::Base.connection.table_exists?(fkey_table)
end