Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Replace map.flatten with flat_map in railties

  • Loading branch information...
commit cff340f1eda96be952437abeed80591a85ef0194 1 parent 3413b88
@sferik sferik authored
View
2  railties/lib/rails/commands/plugin.rb
@@ -11,7 +11,7 @@
end
if File.exist?(railsrc)
extra_args_string = File.read(railsrc)
- extra_args = extra_args_string.split(/\n+/).map {|l| l.split}.flatten
+ extra_args = extra_args_string.split(/\n+/).flat_map {|l| l.split}
puts "Using #{extra_args.join(" ")} from #{railsrc}"
ARGV.insert(1, *extra_args)
end
View
2  railties/lib/rails/generators/actions.rb
@@ -188,7 +188,7 @@ def initializer(filename, data=nil, &block)
# generate(:authenticated, "user session")
def generate(what, *args)
log :generate, what
- argument = args.map {|arg| arg.to_s }.flatten.join(" ")
+ argument = args.flat_map {|arg| arg.to_s }.join(" ")
in_root { run_ruby_script("bin/rails generate #{what} #{argument}", verbose: false) }
end
View
2  railties/lib/rails/paths.rb
@@ -101,7 +101,7 @@ def load_paths
def filter_by(&block)
all_paths.find_all(&block).flat_map { |path|
paths = path.existent
- paths - path.children.map { |p| yield(p) ? [] : p.existent }.flatten
+ paths - path.children.flat_map { |p| yield(p) ? [] : p.existent }
}.uniq
end
end
View
2  railties/lib/rails/source_annotation_extractor.rb
@@ -115,7 +115,7 @@ def extract_annotations_from(file, pattern)
# Prints the mapping from filenames to annotations in +results+ ordered by filename.
# The +options+ hash is passed to each annotation's +to_s+.
def display(results, options={})
- options[:indent] = results.map { |f, a| a.map(&:line) }.flatten.max.to_s.size
+ options[:indent] = results.flat_map { |f, a| a.map(&:line) }.max.to_s.size
results.keys.sort.each do |file|
puts "#{file}:"
results[file].each do |note|
Please sign in to comment.
Something went wrong with that request. Please try again.