Module: Immigrant::ForeignKeyDefinition
- Includes:
- Foreigner::SchemaDumper::ClassMethods
- Defined in:
- lib/immigrant/foreign_key_definition.rb
Overview
add some useful stuff to foreigner’s ForeignKeyDefinition TODO: get more of this into foreigner so we don’t need to monkey patch
Instance Method Summary collapse
- #hash_key ⇒ Object
- #initialize(from_table, to_table, options, *args) ⇒ Object
- #to_ruby(action = :add) ⇒ Object
Instance Method Details
#hash_key ⇒ Object
13 14 15 |
# File 'lib/immigrant/foreign_key_definition.rb', line 13 def hash_key [from_table, [:column]] end |
#initialize(from_table, to_table, options, *args) ⇒ Object
7 8 9 10 11 |
# File 'lib/immigrant/foreign_key_definition.rb', line 7 def initialize(from_table, to_table, , *args) ||= {} [:name] ||= "#{from_table}_#{[:column]}_fk" super(from_table, to_table, , *args) end |
#to_ruby(action = :add) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/immigrant/foreign_key_definition.rb', line 17 def to_ruby(action = :add) if action == :add dump_foreign_key(self) else "remove_foreign_key #{from_table.inspect}, " \ ":name => #{[:name].inspect}" end end |