Sha256: 77c414abd6d21cec447f3e42be9c58507ecad769ec6e7af9eb2b1c08dfba3e11
Contents?: true
Size: 1.14 KB
Versions: 2
Compression:
Stored size: 1.14 KB
Contents
module RedhillonrailsCore module ActiveRecord module 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], name, 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 end end
Version data entries
2 entries across 2 versions & 1 rubygems