Sha256: 169112f8c5fe0db86390aaa65c60472a1ef0f2981aae4c611d57dba6ea0b211a
Contents?: true
Size: 1017 Bytes
Versions: 83
Compression:
Stored size: 1017 Bytes
Contents
module RedHillConsulting::Core::ActiveRecord::ConnectionAdapters module TableDefinition 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 def initialize_with_redhillonrails_core(*args) initialize_without_redhillonrails_core(*args) @foreign_keys = [] end def foreign_key(column_names, references_table_name, references_column_names, options = {}) @foreign_keys << ForeignKeyDefinition.new(options[:name], nil, column_names, ActiveRecord::Migrator.proper_table_name(references_table_name), references_column_names, options[:on_update], options[:on_delete], options[:deferrable]) self end def to_sql_with_redhillonrails_core sql = to_sql_without_redhillonrails_core sql << ', ' << @foreign_keys * ', ' unless @foreign_keys.empty? || ActiveRecord::Schema.defining? sql end end end
Version data entries
83 entries across 83 versions & 5 rubygems