mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Using .try to test for the existence of a method option in a nil-resistent manner. Inlined the determination of the options hash for reversing using a ternary operator. Shortens the method in a way that keeps the code neat
This commit is contained in:
@@ -80,11 +80,8 @@ module ActiveRecord
|
||||
|
||||
def invert_add_index(args)
|
||||
table, columns, options = *args
|
||||
if options && options[:name]
|
||||
options_hash = {:name => options[:name]}
|
||||
else
|
||||
options_hash = {:column => columns}
|
||||
end
|
||||
index_name = options.try(:[], :name)
|
||||
options_hash = index_name ? {:name => index_name} : {:column => columns}
|
||||
[:remove_index, [table, options_hash]]
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user