summaryrefslogtreecommitdiff
path: root/ext/pathname
diff options
context:
space:
mode:
authorschneems <[email protected]>2020-10-26 13:46:40 -0500
committerHiroshi SHIBATA <[email protected]>2024-10-04 12:21:27 +0900
commit3c54b8e9205fa8debe09447138fd08aeaa59e69c ()
treee2ad48df56f57cf3651ca2a44759b7da796a3281 /ext/pathname
parent08346e7267b4f17ae207d67543d5f78c2541dc86 (diff)
Allow method chaining with Pathname#mkpath
Currently in my code when I want to create a pathname object and create a path at the same time I must use tap ``` path = Pathname.new("/tmp/new").tap(&:mkpath) ``` I think it would be cleaner to be able to chain on the results of these methods instead: ``` path = Pathname.new("/tmp/new").mkpath ```
Notes: Merged: https://.com/ruby/ruby/pull/3705
-rw-r--r--ext/pathname/lib/pathname.rb5
1 files changed, 2 insertions, 3 deletions
@@ -588,7 +588,7 @@ class Pathname # * FileUtils *
def mkpath(mode: nil)
require 'fileutils'
FileUtils.mkpath(@path, mode: mode)
- nil
end
# Recursively deletes a directory, including all directories beneath it.
@@ -599,7 +599,7 @@ class Pathname # * FileUtils *
# File::Path provides "mkpath" and "rmtree".
require 'fileutils'
FileUtils.rm_rf(@path, noop: noop, verbose: verbose, secure: secure)
- nil
end
end
@@ -619,4 +619,3 @@ class Pathname # * tmpdir *
end
end
end
-