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.
-
#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 |
# File 'lib/online_migrations/index_definition.rb', line 8 def initialize(**) @table = [:table] @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 |
#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
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/online_migrations/index_definition.rb', line 27 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 other.respond_to?(:opclasses) && opclasses != other.opclasses if unique && !other.unique false else prefix?(self, other) end end |
#intersect?(other) ⇒ Boolean
19 20 21 22 23 24 |
# File 'lib/online_migrations/index_definition.rb', line 19 def intersect?(other) # For ActiveRecord::ConnectionAdapters::IndexDefinition is for expression indexes, # `columns` is a string table == other.table && (columns & Array(other.columns)).any? end |