From 3e036f90c233fbbdc1e2cf15885afab611e90537 Mon Sep 17 00:00:00 2001 From: Holger Frohloff Date: Mon, 2 Feb 2015 20:25:32 +0100 Subject: Small enhancement for generators Changes a call to #map and a subsequent call to #flatten to the more idiomatic version of #flat_map. This commit also removes an unnessecary return statement. --- railties/lib/rails/generators.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/railties/lib/rails/generators.rb b/railties/lib/rails/generators.rb index e25c364178..db8b184213 100644 --- a/railties/lib/rails/generators.rb +++ b/railties/lib/rails/generators.rb @@ -156,7 +156,7 @@ module Rails args << "--help" if args.empty? && klass.arguments.any?(&:required?) klass.start(args, config) else - options = sorted_groups.map(&:last).flatten + options = sorted_groups.flat_map(&:last) suggestions = options.sort_by {|suggested| levenshtein_distance(namespace.to_s, suggested) }.first(3) msg = "Could not find generator '#{namespace}'. " msg << "Maybe you meant #{ suggestions.map {|s| "'#{s}'"}.join(" or ") }\n" @@ -286,7 +286,7 @@ module Rails d[m] = x end - return x + x end # Prints a list of generators. -- cgit v1.2.3