aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--guides/source/contributing_to_ruby_on_rails.md1
-rw-r--r--railties/lib/rails/paths.rb10
2 files changed, 6 insertions, 5 deletions
diff --git a/guides/source/contributing_to_ruby_on_rails.md b/guides/source/contributing_to_ruby_on_rails.md
index 7c5a472971..baef620c6c 100644
--- a/guides/source/contributing_to_ruby_on_rails.md
+++ b/guides/source/contributing_to_ruby_on_rails.md
@@ -216,6 +216,7 @@ Rails follows a simple set of coding style conventions:
* Use `MyClass.my_method(my_arg)` not `my_method( my_arg )` or `my_method my_arg`.
* Use `a = b` and not `a=b`.
* Use assert_not methods instead of refute.
+* Prefer `method { do_stuff }` instead of `method{do_stuff}` for single-line blocks.
* Follow the conventions in the source you see used already.
The above are guidelines — please use your best judgment in using them.
diff --git a/railties/lib/rails/paths.rb b/railties/lib/rails/paths.rb
index e52d1a8b90..de6795eda2 100644
--- a/railties/lib/rails/paths.rb
+++ b/railties/lib/rails/paths.rb
@@ -55,8 +55,8 @@ module Rails
add(path, with: value, glob: glob)
end
- def add(path, options={})
- with = Array(options[:with] || path)
+ def add(path, options = {})
+ with = Array(options.fetch(:with, path))
@root[path] = Path.new(self, path, with, options)
end
@@ -189,9 +189,9 @@ module Rails
path = File.expand_path(p, @root.path)
if @glob && File.directory?(path)
- result.concat Dir.chdir(path) {
- Dir.glob(@glob).map { |file| File.join path, file }.sort
- }
+ Dir.chdir(path) do
+ result.concat(Dir.glob(@glob).map { |file| File.join path, file }.sort)
+ end
else
result << path
end