Method: Convergence::Index#initialize

Defined in:
lib/convergence/index.rb

#initialize(index_name, index_columns, options) ⇒ Index

Returns a new instance of Index.



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/convergence/index.rb', line 4

def initialize(index_name, index_columns, options)
  @index_name = index_name
  @index_columns = [index_columns].flatten.map(&:to_s)
  @options = { name: @index_name }.merge(options)
  length = @options[:length]
  case length
  when Hash
    @options[:length] = Hash[length.map { |k, v| [k.to_s, v] }]
  when Integer
    @options[:length] = Hash[@index_columns.map { |col| [col, length] }]
  end
end