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



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

def from_table
  @from_table
end

#optionsObject

Returns the value of attribute options

Returns:

  • (Object)

    the current value of options



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

def options
  @options
end

#to_tableObject

Returns the value of attribute to_table

Returns:

  • (Object)

    the current value of to_table



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

def to_table
  @to_table
end

Instance Method Details

#columnObject



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

def column
  options[:column]
end

#custom_primary_key?Boolean

Returns:

  • (Boolean)


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

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

#deferrableObject



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

def deferrable
  options[:deferrable]
end

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

Returns:

  • (Boolean)


162
163
164
165
166
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 162

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

#export_name_on_schema_dump?Boolean

Returns:

  • (Boolean)


158
159
160
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 158

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

#nameObject



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

def name
  options[:name]
end

#on_deleteObject



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

def on_delete
  options[:on_delete]
end

#on_updateObject



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

def on_update
  options[:on_update]
end

#primary_keyObject



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

def primary_key
  options[:primary_key] || default_primary_key
end

#validate?Boolean Also known as: validated?

Returns:

  • (Boolean)


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

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