Class: Immigrant::KeyValidator
- Inherits:
-
Object
- Object
- Immigrant::KeyValidator
- Defined in:
- lib/immigrant/key_validator.rb
Instance Method Summary collapse
Instance Method Details
#valid?(key) ⇒ Boolean
3 4 5 6 7 8 9 10 11 |
# File 'lib/immigrant/key_validator.rb', line 3 def valid?(key) tables = connection.tables return false unless tables.include?(key.from_table) return false unless tables.include?(key.to_table) return false unless column_exists?(key.from_table, key.[:column]) return false unless column_exists?(key.to_table, key.[:primary_key]) return false unless key.[:primary_key] == "id" || has_unique_index?(key.to_table, key.[:primary_key]) true end |