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

Version Path
frolic-redhillonrails_core-0.0.1 lib/red_hill_consulting/core/active_record/connection_adapters/table_definition.rb
redhillonrails_core-1.0.9.1 lib/red_hill_consulting/core/active_record/connection_adapters/table_definition.rb
redhillonrails_core-1.0.9 lib/red_hill_consulting/core/active_record/connection_adapters/table_definition.rb
redhillonrails_core-1.0.8 lib/red_hill_consulting/core/active_record/connection_adapters/table_definition.rb
redhillonrails_core-1.0.6 lib/red_hill_consulting/core/active_record/connection_adapters/table_definition.rb
backlog-0.36.2 vendor/plugins/redhillonrails_core/lib/red_hill_consulting/core/active_record/connection_adapters/table_definition.rb
redhillonrails_core-1.0.5 lib/red_hill_consulting/core/active_record/connection_adapters/table_definition.rb
redhillonrails_core-1.0.4.1 lib/red_hill_consulting/core/active_record/connection_adapters/table_definition.rb
redhillonrails_core-1.0.4 lib/red_hill_consulting/core/active_record/connection_adapters/table_definition.rb
redhillonrails_core-1.0.3.1 lib/red_hill_consulting/core/active_record/connection_adapters/table_definition.rb
redhillonrails_core-1.0.3 lib/red_hill_consulting/core/active_record/connection_adapters/table_definition.rb
redhillonrails_core-1.0.2 lib/red_hill_consulting/core/active_record/connection_adapters/table_definition.rb
redhillonrails_core-1.0.1 lib/red_hill_consulting/core/active_record/connection_adapters/table_definition.rb
redhillonrails_core-1.0.0 lib/red_hill_consulting/core/active_record/connection_adapters/table_definition.rb
advertnet-1.0.0 vendor/plugins/redhillonrails_core/lib/red_hill_consulting/core/active_record/connection_adapters/table_definition.rb
advertnet-1.0.1 vendor/plugins/redhillonrails_core/lib/red_hill_consulting/core/active_record/connection_adapters/table_definition.rb
authorails-1.0.0 plugins/redhillonrails_core/lib/red_hill_consulting/core/active_record/connection_adapters/table_definition.rb
backlog-0.10.0 vendor/plugins/redhillonrails_core/lib/red_hill_consulting/core/active_record/connection_adapters/table_definition.rb
backlog-0.10.1 vendor/plugins/redhillonrails_core/lib/red_hill_consulting/core/active_record/connection_adapters/table_definition.rb
backlog-0.10.4 vendor/plugins/redhillonrails_core/lib/red_hill_consulting/core/active_record/connection_adapters/table_definition.rb