# File lib/db_schema/definitions/index.rb, line 16 def primary? @primary end
class DbSchema::Definitions::Index
Attributes
columns[R]
condition[R]
name[R]
type[R]
Public Class Methods
new(name:, columns:, primary: false, unique: false, type: :btree, condition: nil)
click to toggle source
# File lib/db_schema/definitions/index.rb, line 7 def initialize(name:, columns:, primary: false, unique: false, type: :btree, condition: nil) @name = name.to_sym @columns = columns @primary = primary @unique = unique @type = type @condition = condition end
Public Instance Methods
btree?()
click to toggle source
# File lib/db_schema/definitions/index.rb, line 24 def btree? type == :btree end
columns_to_sequel()
click to toggle source
# File lib/db_schema/definitions/index.rb, line 28 def columns_to_sequel if btree? columns.map(&:ordered_expression) else columns.map(&:to_sequel) end end
has_expressions?()
click to toggle source
# File lib/db_schema/definitions/index.rb, line 36 def has_expressions? !condition.nil? || columns.any?(&:expression?) end
primary?()
click to toggle source
unique?()
click to toggle source
# File lib/db_schema/definitions/index.rb, line 20 def unique? @unique end
with_condition(new_condition)
click to toggle source
# File lib/db_schema/definitions/index.rb, line 51 def with_condition(new_condition) Index.new( name: name, columns: columns, primary: primary?, unique: unique?, type: type, condition: new_condition ) end
with_name(new_name)
click to toggle source
# File lib/db_schema/definitions/index.rb, line 40 def with_name(new_name) Index.new( name: new_name, columns: columns, primary: primary?, unique: unique?, type: type, condition: condition ) end