123456789_123456789_123456789_123456789_123456789_

Class: ActiveRecord::ConnectionAdapters::ForeignKeyDefinition

Do not use. This class is for internal use only.
Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, ::Struct
Instance Chain:
self, ::Struct
Inherits: Struct
  • ::Object
Defined in: activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb

Instance Attribute Summary

Instance Method Summary

Instance Attribute Details

#custom_primary_key?Boolean (readonly)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 148

def custom_primary_key?
  options[:primary_key] != default_primary_key
end

#export_name_on_schema_dump?Boolean (readonly)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 157

def export_name_on_schema_dump?
  !ActiveRecord::SchemaDumper.fk_ignore_pattern.match?(name) if name
end

#from_table (rw)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 123

ForeignKeyDefinition = Struct.new(:from_table, :to_table, :options)

#options (rw)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 123

ForeignKeyDefinition = Struct.new(:from_table, :to_table, :options)

#to_table (rw)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 123

ForeignKeyDefinition = Struct.new(:from_table, :to_table, :options)

#validate?Boolean (readonly) Also known as: #validated?

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 152

def validate?
  options.fetch(:validate, true)
end

#validated? (readonly)

Alias for #validate?.

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 155

alias validated? validate?

Instance Method Details

#column

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 128

def column
  options[:column]
end

#default_primary_key (private)

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 168

def default_primary_key
  "id"
end

#deferrable

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 144

def deferrable
  options[:deferrable]
end

#defined_for?(to_table: nil, validate: nil, **options) ⇒ Boolean

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 161

def defined_for?(to_table: nil, validate: nil, **options)
  (to_table.nil? || to_table.to_s == self.to_table) &&
    (validate.nil? || validate == self.options.fetch(:validate, validate)) &&
    options.all? { |k, v| Array(self.options[k]).map(&:to_s) == Array(v).map(&:to_s) }
end

#name

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 124

def name
  options[:name]
end

#on_delete

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 136

def on_delete
  options[:on_delete]
end

#on_update

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 140

def on_update
  options[:on_update]
end

#primary_key

[ GitHub ]

  
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 132

def primary_key
  options[:primary_key] || default_primary_key
end