Class: FastChangeTable::InstanceMethods::PhoneyIndex

Inherits:
Object
  • Object
show all
Defined in:
lib/fast_change_table/fast_change_table.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(table, cols, options) ⇒ PhoneyIndex

Returns a new instance of PhoneyIndex.



132
133
134
135
136
137
138
139
# File 'lib/fast_change_table/fast_change_table.rb', line 132

def initialize(table, cols, options)
  cols = [cols].flatten
  self.columns = cols.collect(&:to_s)
  self.lengths = options[:length]
  self.unique = !!options[:unique]
  self.name = options[:name] || "index_#{table}_on_#{columns.join('_and_')}"
  self.name = "#{columns.join('_')}_idx" if name.length > 64
end

Instance Attribute Details

#columnsObject

Returns the value of attribute columns.



130
131
132
# File 'lib/fast_change_table/fast_change_table.rb', line 130

def columns
  @columns
end

#lengthsObject

Returns the value of attribute lengths.



130
131
132
# File 'lib/fast_change_table/fast_change_table.rb', line 130

def lengths
  @lengths
end

#nameObject

Returns the value of attribute name.



130
131
132
# File 'lib/fast_change_table/fast_change_table.rb', line 130

def name
  @name
end

#uniqueObject

Returns the value of attribute unique.



130
131
132
# File 'lib/fast_change_table/fast_change_table.rb', line 130

def unique
  @unique
end

Instance Method Details

#==(val) ⇒ Object



141
142
143
# File 'lib/fast_change_table/fast_change_table.rb', line 141

def ==(val)
  columns == val.columns rescue false
end