Class: ActiveRecord::ConnectionAdapters::IndexDefinition
- Inherits:
-
Object
- Object
- ActiveRecord::ConnectionAdapters::IndexDefinition
- Defined in:
- lib/active_record/connection_adapters/abstract/schema_definitions.rb
Overview
Abstract representation of an index definition on a table. Instances of this type are typically created and returned by methods in database adapters. e.g. ActiveRecord::ConnectionAdapters::MySQL::SchemaStatements#indexes
Instance Attribute Summary collapse
-
#columns ⇒ Object
readonly
:nodoc:.
-
#comment ⇒ Object
readonly
:nodoc:.
-
#include ⇒ Object
readonly
:nodoc:.
-
#lengths ⇒ Object
readonly
:nodoc:.
-
#name ⇒ Object
readonly
:nodoc:.
-
#nulls_not_distinct ⇒ Object
readonly
:nodoc:.
-
#opclasses ⇒ Object
readonly
:nodoc:.
-
#orders ⇒ Object
readonly
:nodoc:.
-
#table ⇒ Object
readonly
:nodoc:.
-
#type ⇒ Object
readonly
:nodoc:.
-
#unique ⇒ Object
readonly
:nodoc:.
-
#using ⇒ Object
readonly
:nodoc:.
-
#valid ⇒ Object
readonly
:nodoc:.
-
#where ⇒ Object
readonly
:nodoc:.
Instance Method Summary collapse
- #column_options ⇒ Object
- #defined_for?(columns = nil, name: nil, unique: nil, valid: nil, include: nil, nulls_not_distinct: nil, **options) ⇒ Boolean
-
#initialize(table, name, unique = false, columns = [], lengths: {}, orders: {}, opclasses: {}, where: nil, type: nil, using: nil, include: nil, nulls_not_distinct: nil, comment: nil, valid: true) ⇒ IndexDefinition
constructor
A new instance of IndexDefinition.
- #valid? ⇒ Boolean
Constructor Details
#initialize(table, name, unique = false, columns = [], lengths: {}, orders: {}, opclasses: {}, where: nil, type: nil, using: nil, include: nil, nulls_not_distinct: nil, comment: nil, valid: true) ⇒ IndexDefinition
Returns a new instance of IndexDefinition.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 11 def initialize( table, name, unique = false, columns = [], lengths: {}, orders: {}, opclasses: {}, where: nil, type: nil, using: nil, include: nil, nulls_not_distinct: nil, comment: nil, valid: true ) @table = table @name = name @unique = unique @columns = columns @lengths = (lengths) @orders = (orders) @opclasses = (opclasses) @where = where @type = type @using = using @include = include @nulls_not_distinct = nulls_not_distinct @comment = comment @valid = valid end |
Instance Attribute Details
#columns ⇒ Object (readonly)
:nodoc:
9 10 11 |
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 9 def columns @columns end |
#comment ⇒ Object (readonly)
:nodoc:
9 10 11 |
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 9 def comment @comment end |
#include ⇒ Object (readonly)
:nodoc:
9 10 11 |
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 9 def include @include end |
#lengths ⇒ Object (readonly)
:nodoc:
9 10 11 |
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 9 def lengths @lengths end |
#name ⇒ Object (readonly)
:nodoc:
9 10 11 |
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 9 def name @name end |
#nulls_not_distinct ⇒ Object (readonly)
:nodoc:
9 10 11 |
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 9 def nulls_not_distinct @nulls_not_distinct end |
#opclasses ⇒ Object (readonly)
:nodoc:
9 10 11 |
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 9 def opclasses @opclasses end |
#orders ⇒ Object (readonly)
:nodoc:
9 10 11 |
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 9 def orders @orders end |
#table ⇒ Object (readonly)
:nodoc:
9 10 11 |
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 9 def table @table end |
#type ⇒ Object (readonly)
:nodoc:
9 10 11 |
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 9 def type @type end |
#unique ⇒ Object (readonly)
:nodoc:
9 10 11 |
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 9 def unique @unique end |
#using ⇒ Object (readonly)
:nodoc:
9 10 11 |
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 9 def using @using end |
#valid ⇒ Object (readonly)
:nodoc:
9 10 11 |
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 9 def valid @valid end |
#where ⇒ Object (readonly)
:nodoc:
9 10 11 |
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 9 def where @where end |
Instance Method Details
#column_options ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 46 def { length: lengths, order: orders, opclass: opclasses, } end |
#defined_for?(columns = nil, name: nil, unique: nil, valid: nil, include: nil, nulls_not_distinct: nil, **options) ⇒ Boolean
54 55 56 57 58 59 60 61 62 |
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 54 def defined_for?(columns = nil, name: nil, unique: nil, valid: nil, include: nil, nulls_not_distinct: nil, **) columns = [:column] if columns.blank? (columns.nil? || Array(self.columns) == Array(columns).map(&:to_s)) && (name.nil? || self.name == name.to_s) && (unique.nil? || self.unique == unique) && (valid.nil? || self.valid == valid) && (include.nil? || Array(self.include) == Array(include).map(&:to_s)) && (nulls_not_distinct.nil? || self.nulls_not_distinct == nulls_not_distinct) end |
#valid? ⇒ Boolean
42 43 44 |
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 42 def valid? @valid end |