From c60995f31d98f2f11110516095fb35226278d960 Mon Sep 17 00:00:00 2001 From: Damien Mathieu <42@dmathieu.com> Date: Thu, 8 Sep 2011 11:08:50 +0200 Subject: better method documentation on disable safe string methods --- .../active_support/core_ext/string/output_safety.rb | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'activesupport') diff --git a/activesupport/lib/active_support/core_ext/string/output_safety.rb b/activesupport/lib/active_support/core_ext/string/output_safety.rb index 24b617578f..6e8f72e2b3 100644 --- a/activesupport/lib/active_support/core_ext/string/output_safety.rb +++ b/activesupport/lib/active_support/core_ext/string/output_safety.rb @@ -157,13 +157,19 @@ module ActiveSupport #:nodoc: 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 -- cgit v1.2.3