Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

override unsafe methods only if defined on String

  • Loading branch information...
commit 9257a21f7aece4b50d6228f48424753561229713 1 parent d9d1bb2
@amatsuda amatsuda authored
Showing with 12 additions and 10 deletions.
  1. +12 −10 activesupport/lib/active_support/core_ext/string/output_safety.rb
View
22 activesupport/lib/active_support/core_ext/string/output_safety.rb
@@ -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.