Class: Dart::NamingConventions::ForeignKeyFinder
- Inherits:
-
Object
- Object
- Dart::NamingConventions::ForeignKeyFinder
- Defined in:
- lib/dart/naming_conventions/foreign_key_finder.rb
Instance Method Summary collapse
-
#foreign_keys_for(relation, schema) ⇒ Object
Returns a set of possible foreign keys based on columns in this relation matching the naming convention and reference a table name that is in the given schema.
Instance Method Details
#foreign_keys_for(relation, schema) ⇒ Object
Returns a set of possible foreign keys based on columns in this relation matching the naming convention and reference a table name that is in the given schema
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/dart/naming_conventions/foreign_key_finder.rb', line 11 def foreign_keys_for(relation, schema) naming_conventions = Dart::NamingConventions.instance relation.column_names.map do |possible_foreign_key| if parent_table = naming_conventions.parent_table_for(possible_foreign_key) if schema.has_table?(parent_table) ForeignKeyInfo.new(relation.table_name, possible_foreign_key, parent_table, naming_conventions.conventional_primary_key) end end end.compact end |