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



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

def from_table
  @from_table
end

#optionsObject

Returns the value of attribute options

Returns:

  • (Object)

    the current value of options



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

def options
  @options
end

#to_tableObject

Returns the value of attribute to_table

Returns:

  • (Object)

    the current value of to_table



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

def to_table
  @to_table
end

Instance Method Details

#columnObject



93
94
95
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 93

def column
  options[:column]
end

#custom_primary_key?Boolean

Returns:

  • (Boolean)


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

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

#deferrableObject



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

def deferrable
  options[:deferrable]
end

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

Returns:

  • (Boolean)


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

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)


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

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

#nameObject



89
90
91
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 89

def name
  options[:name]
end

#on_deleteObject



101
102
103
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 101

def on_delete
  options[:on_delete]
end

#on_updateObject



105
106
107
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 105

def on_update
  options[:on_update]
end

#primary_keyObject



97
98
99
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 97

def primary_key
  options[:primary_key] || default_primary_key
end

#validate?Boolean Also known as: validated?

Returns:

  • (Boolean)


117
118
119
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 117

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