Browse files

Refactor index algorithm lookup so that it only builds the available …

…options once

This way the available options are only built for actually fetching the
algorithm in case the option is given.

The options are going to be necessary a second time only in case the option
is given but does not exist, which is supposed to be due to a typo or
something like that, so no problem.
  • Loading branch information...
1 parent 07dfc0a commit 2d1eebfd88861d9eab541041a25f3f57d3cf90c7 @carlosantoniodasilva carlosantoniodasilva committed Mar 30, 2013
@@ -774,10 +774,10 @@ def add_index_options(table_name, column_name, options = {})
index_name = options[:name].to_s if options.key?(:name)
max_index_length = options.fetch(:internal, false) ? index_name_length : allowed_index_name_length
- if index_algorithms.key?(options[:algorithm])
- algorithm = index_algorithms[options[:algorithm]]
- elsif options[:algorithm].present?
- raise"Algorithm must be one of the following: #{', ')}")
+ if options.key?(:algorithm)
+ algorithm = index_algorithms.fetch(options[:algorithm]) {
+ raise"Algorithm must be one of the following: #{', ')}")
+ }
using = "USING #{options[:using]}" if options[:using].present?

0 comments on commit 2d1eebf

Please sign in to comment.