Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Using .try to test for the existence of a method option in a nil-resi…

…stent 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
  • Loading branch information...
commit 86afbf7464e96dd156895eba2fa44b41678cdd6e 1 parent 8588dd4
@workmad3 workmad3 authored
Showing with 2 additions and 5 deletions.
  1. +2 −5 activerecord/lib/active_record/migration/command_recorder.rb
7 activerecord/lib/active_record/migration/command_recorder.rb
@@ -80,11 +80,8 @@ def invert_rename_column(args)
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]]
Please sign in to comment.
Something went wrong with that request. Please try again.