Class: AssociationReporter::OneToManyAssociationAssumption
Instance Method Summary
collapse
#assoc_klass, #assoc_klass_label, #assoc_klass_name, #assoc_table, #assoc_table_label, #valid_table?
Methods inherited from Assumption
#initialize
Instance Method Details
#fkey_column ⇒ Object
106
107
108
|
# File 'lib/association-reporter/assumption.rb', line 106
def fkey_column
reflection.foreign_key
end
|
#fkey_column_label ⇒ Object
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_table ⇒ Object
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_label ⇒ Object
102
103
104
|
# File 'lib/association-reporter/assumption.rb', line 102
def fkey_table_label
labelize(fkey_table, valid_fkey_table?)
end
|
#valid? ⇒ 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
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
114
115
116
|
# File 'lib/association-reporter/assumption.rb', line 114
def valid_fkey_table?
ActiveRecord::Base.connection.table_exists?(fkey_table)
end
|