Permalink
Browse files

Merge pull request #2931 from dmathieu/safe_gsub_doc

better method documentation on disable safe string methods
  • Loading branch information...
2 parents b4a6e2f + c60995f commit 06b218dd957d7454d75eeac301a1853793a631f8 @vijaydev vijaydev committed Sep 8, 2011
Showing with 12 additions and 6 deletions.
  1. +12 −6 activesupport/lib/active_support/core_ext/string/output_safety.rb
@@ -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

0 comments on commit 06b218d

Please sign in to comment.