aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTee Parham <tee@neighborland.com>2014-09-06 11:02:40 -0600
committerTee Parham <tee@neighborland.com>2014-09-07 16:52:01 -0600
commit95456eb4efd5bbfb6ff1cca429b9b146708f4f18 (patch)
tree7e1919b1ea7c69a3f08b70f293890977670a9dc7
parent4a1e2c32532ee0f6ee08563d7970c9220d9e2773 (diff)
downloadrails-95456eb4efd5bbfb6ff1cca429b9b146708f4f18.tar.gz
rails-95456eb4efd5bbfb6ff1cca429b9b146708f4f18.tar.bz2
rails-95456eb4efd5bbfb6ff1cca429b9b146708f4f18.zip
Prefer "if any?" to "unless empty?"
* Consistent whitespace * Remove unnecessary parentheses
-rw-r--r--activerecord/lib/active_record/schema_dumper.rb15
1 files changed, 6 insertions, 9 deletions
diff --git a/activerecord/lib/active_record/schema_dumper.rb b/activerecord/lib/active_record/schema_dumper.rb
index 6f70a61993..4888907f51 100644
--- a/activerecord/lib/active_record/schema_dumper.rb
+++ b/activerecord/lib/active_record/schema_dumper.rb
@@ -195,15 +195,12 @@ HEADER
statement_parts << 'unique: true' if index.unique
index_lengths = (index.lengths || []).compact
- statement_parts << "length: #{Hash[index.columns.zip(index.lengths)].inspect}" unless index_lengths.empty?
-
- index_orders = (index.orders || {})
- statement_parts << "order: #{index.orders.inspect}" unless index_orders.empty?
+ statement_parts << "length: #{Hash[index.columns.zip(index.lengths)].inspect}" if index_lengths.any?
+ index_orders = index.orders || {}
+ statement_parts << "order: #{index.orders.inspect}" if index_orders.any?
statement_parts << "where: #{index.where.inspect}" if index.where
-
statement_parts << "using: #{index.using.inspect}" if index.using
-
statement_parts << "type: #{index.type.inspect}" if index.type
" #{statement_parts.join(', ')}"
@@ -218,9 +215,9 @@ HEADER
if (foreign_keys = @connection.foreign_keys(table)).any?
add_foreign_key_statements = foreign_keys.map do |foreign_key|
parts = [
- "add_foreign_key #{remove_prefix_and_suffix(foreign_key.from_table).inspect}",
- remove_prefix_and_suffix(foreign_key.to_table).inspect,
- ]
+ "add_foreign_key #{remove_prefix_and_suffix(foreign_key.from_table).inspect}",
+ remove_prefix_and_suffix(foreign_key.to_table).inspect,
+ ]
if foreign_key.column != @connection.foreign_key_column_for(foreign_key.to_table)
parts << "column: #{foreign_key.column.inspect}"