Class: Convergence::Index
- Inherits:
-
Object
- Object
- Convergence::Index
- Defined in:
- lib/convergence/index.rb
Instance Attribute Summary collapse
-
#index_columns ⇒ Object
Returns the value of attribute index_columns.
-
#index_name ⇒ Object
Returns the value of attribute index_name.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(index_name, index_columns, options) ⇒ Index
constructor
A new instance of Index.
- #quoted_columns ⇒ Object
Constructor Details
#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, ) @index_name = index_name @index_columns = [index_columns].flatten.map(&:to_s) @options = { name: @index_name }.merge() 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 |
Instance Attribute Details
#index_columns ⇒ Object
Returns the value of attribute index_columns.
2 3 4 |
# File 'lib/convergence/index.rb', line 2 def index_columns @index_columns end |
#index_name ⇒ Object
Returns the value of attribute index_name.
2 3 4 |
# File 'lib/convergence/index.rb', line 2 def index_name @index_name end |
#options ⇒ Object
Returns the value of attribute options.
2 3 4 |
# File 'lib/convergence/index.rb', line 2 def @options end |
Instance Method Details
#quoted_columns ⇒ Object
17 18 19 20 21 |
# File 'lib/convergence/index.rb', line 17 def quoted_columns option_strings = Hash[@index_columns.map { |name| [name, ''] }] option_strings = add_index_length(option_strings, @index_columns, @options) @index_columns.map { |name| quote_column_name(name) + option_strings[name] } end |