Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #3230 from amatsuda/string_prepend_31

ruby193: String#prepend for 3-1-stable
  • Loading branch information...
commit fc9b52173c5bf70213de04bdab2efecf45748e43 2 parents c6d13b6 + aa11f73
@josevalim josevalim authored
Showing with 13 additions and 11 deletions.
  1. +13 −11 activesupport/lib/active_support/core_ext/string/output_safety.rb
View
24 activesupport/lib/active_support/core_ext/string/output_safety.rb
@@ -75,7 +75,7 @@ def html_safe?
module ActiveSupport #:nodoc:
class SafeBuffer < String
- UNSAFE_STRING_METHODS = ["capitalize", "chomp", "chop", "delete", "downcase", "gsub", "lstrip", "next", "reverse", "rstrip", "slice", "squeeze", "strip", "sub", "succ", "swapcase", "tr", "tr_s", "upcase"].freeze
+ UNSAFE_STRING_METHODS = ["capitalize", "chomp", "chop", "delete", "downcase", "gsub", "lstrip", "next", "reverse", "rstrip", "slice", "squeeze", "strip", "sub", "succ", "swapcase", "tr", "tr_s", "upcase", "prepend"].freeze
alias_method :original_concat, :concat
private :original_concat
@@ -136,16 +136,18 @@ def to_yaml(*args)
end
for unsafe_method in UNSAFE_STRING_METHODS
- class_eval <<-EOT, __FILE__, __LINE__ + 1
- def #{unsafe_method}(*args)
- super.to_str
- end
-
- def #{unsafe_method}!(*args)
- @dirty = true
- super
- end
- EOT
+ if 'String'.respond_to?(unsafe_method)
+ class_eval <<-EOT, __FILE__, __LINE__ + 1
+ def #{unsafe_method}(*args)
+ super.to_str
+ end
+
+ def #{unsafe_method}!(*args)
+ @dirty = true
+ super
+ end
+ EOT
+ end
end
protected
Please sign in to comment.
Something went wrong with that request. Please try again.