提交 c60995f3 编写于 作者: D Damien Mathieu

better method documentation on disable safe string methods

上级 b4a6e2f8
......@@ -157,13 +157,19 @@ def #{unsafe_method}!(*args) # def capitalize!(*args)
UNAVAILABLE_STRING_METHODS.each do |unavailable_method|
class_eval <<-EOT, __FILE__, __LINE__
def #{unavailable_method}(*args) # def gsub(*args)
# def gsub(*args)
# raise NoMethodError, "gsub cannot be used with a Safe Buffer object. You should use object.to_str.gsub"
# end
def #{unavailable_method}(*args)
raise NoMethodError, "#{unavailable_method} cannot be used with a Safe Buffer object. You should use object.to_str.#{unavailable_method}"
end # end
def #{unavailable_method}!(*args) # def gsub!(*args)
raise NoMethodError, "#{unavailable_method} cannot be used with a Safe Buffer object. You should use object.to_str.#{unavailable_method}"
end # end
end
# def gsub!(*args)
# raise NoMethodError, "gsub! cannot be used with a Safe Buffer object. You should use object.to_str.gsub!"
# end
def #{unavailable_method}!(*args)
raise NoMethodError, "#{unavailable_method}! cannot be used with a Safe Buffer object. You should use object.to_str.#{unavailable_method}!"
end
EOT
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册