Class: ActiveRecord::ConnectionAdapters::ForeignKeyDefinition

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

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Struct

#as_json

Instance Attribute Details

#from_tableObject

Returns the value of attribute from_table

Returns:

  • (Object)

    the current value of from_table



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

def from_table
  @from_table
end

#optionsObject

Returns the value of attribute options

Returns:

  • (Object)

    the current value of options



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

def options
  @options
end

#to_tableObject

Returns the value of attribute to_table

Returns:

  • (Object)

    the current value of to_table



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

def to_table
  @to_table
end

Instance Method Details

#columnObject



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

def column
  options[:column]
end

#custom_primary_key?Boolean

Returns:

  • (Boolean)


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

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

#deferrableObject



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

def deferrable
  options[:deferrable]
end

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

Returns:

  • (Boolean)


159
160
161
162
163
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 159

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| self.options[k].to_s == v.to_s }
end

#export_name_on_schema_dump?Boolean

Returns:

  • (Boolean)


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

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

#nameObject



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

def name
  options[:name]
end

#on_deleteObject



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

def on_delete
  options[:on_delete]
end

#on_updateObject



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

def on_update
  options[:on_update]
end

#primary_keyObject



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

def primary_key
  options[:primary_key] || default_primary_key
end

#validate?Boolean Also known as: validated?

Returns:

  • (Boolean)


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

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