Class: OnlineMigrations::IndexDefinition
- Inherits:
-
Object
- Object
- OnlineMigrations::IndexDefinition
- Defined in:
- lib/online_migrations/index_definition.rb
Instance Attribute Summary collapse
-
#columns ⇒ Object
readonly
Returns the value of attribute columns.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#opclasses ⇒ Object
readonly
Returns the value of attribute opclasses.
-
#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.
-
#where ⇒ Object
readonly
Returns the value of attribute where.
Instance Method Summary collapse
- #covered_by?(other) ⇒ Boolean
-
#initialize(**options) ⇒ IndexDefinition
constructor
A new instance of IndexDefinition.
- #intersect?(other) ⇒ Boolean
Constructor Details
#initialize(**options) ⇒ IndexDefinition
Returns a new instance of IndexDefinition.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/online_migrations/index_definition.rb', line 8 def initialize(**) @table = [:table]&.to_s @name = [:name]&.to_s @columns = Array([:columns]).map(&:to_s) @unique = [:unique] @opclasses = [:opclass] || {} @where = [:where] @type = [:type] @using = [:using] || :btree end |
Instance Attribute Details
#columns ⇒ Object (readonly)
Returns the value of attribute columns.
6 7 8 |
# File 'lib/online_migrations/index_definition.rb', line 6 def columns @columns end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/online_migrations/index_definition.rb', line 6 def name @name end |
#opclasses ⇒ Object (readonly)
Returns the value of attribute opclasses.
6 7 8 |
# File 'lib/online_migrations/index_definition.rb', line 6 def opclasses @opclasses end |
#table ⇒ Object (readonly)
Returns the value of attribute table.
6 7 8 |
# File 'lib/online_migrations/index_definition.rb', line 6 def table @table end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
6 7 8 |
# File 'lib/online_migrations/index_definition.rb', line 6 def type @type end |
#unique ⇒ Object (readonly)
Returns the value of attribute unique.
6 7 8 |
# File 'lib/online_migrations/index_definition.rb', line 6 def unique @unique end |
#using ⇒ Object (readonly)
Returns the value of attribute using.
6 7 8 |
# File 'lib/online_migrations/index_definition.rb', line 6 def using @using end |
#where ⇒ Object (readonly)
Returns the value of attribute where.
6 7 8 |
# File 'lib/online_migrations/index_definition.rb', line 6 def where @where end |
Instance Method Details
#covered_by?(other) ⇒ Boolean
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/online_migrations/index_definition.rb', line 28 def covered_by?(other) return false if type != other.type return false if using != other.using return false if where != other.where return false if opclasses != other.opclasses if unique && !other.unique false else prefix?(self, other) end end |
#intersect?(other) ⇒ Boolean
20 21 22 23 24 25 |
# File 'lib/online_migrations/index_definition.rb', line 20 def intersect?(other) # For ActiveRecord::ConnectionAdapters::IndexDefinition is for expression indexes, # `columns` is a string table == other.table && ((name && name == other.name) || columns.intersect?(Array(other.columns))) end |