Class: ActiveRecord::ConnectionAdapters::ForeignKeyDefinition

Inherits:
Struct
  • Object
show all
Defined in:
lib/active_record/connection_adapters/abstract/schema_definitions.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#from_tableObject

Returns the value of attribute from_table

Returns:

  • (Object)

    the current value of from_table



78
79
80
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 78

def from_table
  @from_table
end

#optionsObject

Returns the value of attribute options

Returns:

  • (Object)

    the current value of options



78
79
80
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 78

def options
  @options
end

#to_tableObject

Returns the value of attribute to_table

Returns:

  • (Object)

    the current value of to_table



78
79
80
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 78

def to_table
  @to_table
end

Instance Method Details

#columnObject



83
84
85
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 83

def column
  options[:column]
end

#custom_primary_key?Boolean

Returns:

  • (Boolean)


99
100
101
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 99

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

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

Returns:

  • (Boolean)


112
113
114
115
116
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 112

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

#export_name_on_schema_dump?Boolean

Returns:

  • (Boolean)


108
109
110
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 108

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

#nameObject



79
80
81
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 79

def name
  options[:name]
end

#on_deleteObject



91
92
93
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 91

def on_delete
  options[:on_delete]
end

#on_updateObject



95
96
97
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 95

def on_update
  options[:on_update]
end

#primary_keyObject



87
88
89
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 87

def primary_key
  options[:primary_key] || default_primary_key
end

#validate?Boolean Also known as: validated?

Returns:

  • (Boolean)


103
104
105
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 103

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