Deprecate Pathname#/ with non-string/non-pathname arguments
Ruby 2.2 will define Pathname#/ as a simple alias of Pathname#+. In practice, this means that it will raise a TypeError unless the argument responds to to_path or to_str. Currently we blindly convert the argument to a string using to_s, so deprecate this in the interest of matching the upstream behavior. In the future we can replace this with alias_method :/, :+ unless method_defined?(:/) Closes Homebrew/homebrew#30079.
This commit is contained in:
parent
6eb7e0c27f
commit
faaa622820
@ -301,8 +301,12 @@ class Pathname
|
|||||||
File.symlink(src.relative_path_from(dirname), self)
|
File.symlink(src.relative_path_from(dirname), self)
|
||||||
end
|
end
|
||||||
|
|
||||||
def / that
|
def /(other)
|
||||||
self + that.to_s
|
unless other.respond_to?(:to_str) || other.respond_to?(:to_path)
|
||||||
|
opoo "Pathname#/ called on #{inspect} with #{other.inspect} as an argument"
|
||||||
|
puts "This behavior is deprecated, please pass either a String or a Pathname"
|
||||||
|
end
|
||||||
|
self + other.to_s
|
||||||
end unless method_defined?(:/)
|
end unless method_defined?(:/)
|
||||||
|
|
||||||
def ensure_writable
|
def ensure_writable
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user