Skip to content

Commit

Permalink
Merge pull request #2931 from dmathieu/safe_gsub_doc
Browse files Browse the repository at this point in the history
better method documentation on disable safe string methods
  • Loading branch information
vijaydev committed Sep 8, 2011
2 parents b4a6e2f + c60995f commit 06b218d
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions activesupport/lib/active_support/core_ext/string/output_safety.rb
Expand Up @@ -157,13 +157,19 @@ def #{unsafe_method}!(*args) # def capitalize!(*args)


UNAVAILABLE_STRING_METHODS.each do |unavailable_method| UNAVAILABLE_STRING_METHODS.each do |unavailable_method|
class_eval <<-EOT, __FILE__, __LINE__ 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}" raise NoMethodError, "#{unavailable_method} cannot be used with a Safe Buffer object. You should use object.to_str.#{unavailable_method}"
end # end end
def #{unavailable_method}!(*args) # def gsub!(*args) # def gsub!(*args)
raise NoMethodError, "#{unavailable_method} cannot be used with a Safe Buffer object. You should use object.to_str.#{unavailable_method}" # raise NoMethodError, "gsub! cannot be used with a Safe Buffer object. You should use object.to_str.gsub!"
end # end # 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 EOT
end end


Expand Down

0 comments on commit 06b218d

Please sign in to comment.