Class: ActiveRecord::ConnectionAdapters::IndexDefinition
- Defined in:
- activerecord/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
Returns the value of attribute columns.
-
#comment ⇒ Object
readonly
Returns the value of attribute comment.
-
#include ⇒ Object
readonly
Returns the value of attribute include.
-
#lengths ⇒ Object
readonly
Returns the value of attribute lengths.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#opclasses ⇒ Object
readonly
Returns the value of attribute opclasses.
-
#orders ⇒ Object
readonly
Returns the value of attribute orders.
-
#table ⇒ Object
readonly
Returns the value of attribute table.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#unique ⇒ Object
readonly
Returns the value of attribute unique.
-
#using ⇒ Object
readonly
Returns the value of attribute using.
-
#valid ⇒ Object
readonly
Returns the value of attribute valid.
-
#where ⇒ Object
readonly
Returns the value of attribute where.
Instance Method Summary collapse
- #column_options ⇒ Object
- #defined_for?(columns = nil, name: nil, unique: nil, valid: nil, include: nil, **options) ⇒ Boolean
-
#initialize(table, name, unique = false, columns = [], lengths: {}, orders: {}, opclasses: {}, where: nil, type: nil, using: nil, include: 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, comment: nil, valid: true) ⇒ IndexDefinition
Returns a new instance of IndexDefinition.
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 |
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 12 def initialize( table, name, unique = false, columns = [], lengths: {}, orders: {}, opclasses: {}, where: nil, type: nil, using: nil, include: 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 @comment = comment @valid = valid end |
Instance Attribute Details
#columns ⇒ Object (readonly)
Returns the value of attribute columns
10 11 12 |
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 10 def columns @columns end |
#comment ⇒ Object (readonly)
Returns the value of attribute comment
10 11 12 |
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 10 def comment @comment end |
#include ⇒ Object (readonly)
Returns the value of attribute include
10 11 12 |
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 10 def include @include end |
#lengths ⇒ Object (readonly)
Returns the value of attribute lengths
10 11 12 |
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 10 def lengths @lengths end |
#name ⇒ Object (readonly)
Returns the value of attribute name
10 11 12 |
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 10 def name @name end |
#opclasses ⇒ Object (readonly)
Returns the value of attribute opclasses
10 11 12 |
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 10 def opclasses @opclasses end |
#orders ⇒ Object (readonly)
Returns the value of attribute orders
10 11 12 |
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 10 def orders @orders end |
#table ⇒ Object (readonly)
Returns the value of attribute table
10 11 12 |
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 10 def table @table end |
#type ⇒ Object (readonly)
Returns the value of attribute type
10 11 12 |
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 10 def type @type end |
#unique ⇒ Object (readonly)
Returns the value of attribute unique
10 11 12 |
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 10 def unique @unique end |
#using ⇒ Object (readonly)
Returns the value of attribute using
10 11 12 |
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 10 def using @using end |
#valid ⇒ Object (readonly)
Returns the value of attribute valid
10 11 12 |
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 10 def valid @valid end |
#where ⇒ Object (readonly)
Returns the value of attribute where
10 11 12 |
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 10 def where @where end |
Instance Method Details
#column_options ⇒ Object
45 46 47 48 49 50 51 |
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 45 def { length: lengths, order: orders, opclass: opclasses, } end |
#defined_for?(columns = nil, name: nil, unique: nil, valid: nil, include: nil, **options) ⇒ Boolean
53 54 55 56 57 58 59 60 |
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 53 def defined_for?(columns = nil, name: nil, unique: nil, valid: nil, include: 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)) end |
#valid? ⇒ Boolean
41 42 43 |
# File 'activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 41 def valid? @valid end |