Module: RedhillonrailsCore::ActiveRecord::ConnectionAdapters::TableDefinition
- Defined in:
- lib/redhillonrails_core/active_record/connection_adapters/table_definition.rb
Class Method Summary collapse
Instance Method Summary collapse
- #foreign_key(column_names, references_table_name, references_column_names, options = {}) ⇒ Object
- #initialize_with_redhillonrails_core(*args) ⇒ Object
- #to_sql_with_redhillonrails_core ⇒ Object
Class Method Details
.included(base) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/redhillonrails_core/active_record/connection_adapters/table_definition.rb', line 5 def self.included(base) base.class_eval do attr_accessor :name alias_method_chain :initialize, :redhillonrails_core alias_method_chain :to_sql, :redhillonrails_core end end |
Instance Method Details
#foreign_key(column_names, references_table_name, references_column_names, options = {}) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/redhillonrails_core/active_record/connection_adapters/table_definition.rb', line 18 def foreign_key(column_names, references_table_name, references_column_names, = {}) @foreign_keys << ForeignKeyDefinition.new([:name], name, column_names, ::ActiveRecord::Migrator.proper_table_name(references_table_name), references_column_names, [:on_update], [:on_delete], [:deferrable]) self end |
#initialize_with_redhillonrails_core(*args) ⇒ Object
13 14 15 16 |
# File 'lib/redhillonrails_core/active_record/connection_adapters/table_definition.rb', line 13 def initialize_with_redhillonrails_core(*args) initialize_without_redhillonrails_core(*args) @foreign_keys = [] end |
#to_sql_with_redhillonrails_core ⇒ Object
25 26 27 28 29 |
# File 'lib/redhillonrails_core/active_record/connection_adapters/table_definition.rb', line 25 def to_sql_with_redhillonrails_core sql = to_sql_without_redhillonrails_core sql << ', ' << @foreign_keys * ', ' unless @foreign_keys.empty? || ::ActiveRecord::Schema.defining? sql end |