aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/string
diff options
context:
space:
mode:
authoraditya-kapoor <aditya.kapoor@vinsol.com>2013-05-14 01:09:03 +0530
committeraditya-kapoor <aditya.kapoor@vinsol.com>2013-05-14 01:09:03 +0530
commit069ea45c5d4b0215d4aa3ce57316cfbc8db5ba9e (patch)
tree9278c7ac4bc72dc4f9b434a47b1215ea76d10094 /activesupport/lib/active_support/core_ext/string
parent37ca5b09662797928a4f74878595a4e577c5aedd (diff)
downloadrails-069ea45c5d4b0215d4aa3ce57316cfbc8db5ba9e.tar.gz
rails-069ea45c5d4b0215d4aa3ce57316cfbc8db5ba9e.tar.bz2
rails-069ea45c5d4b0215d4aa3ce57316cfbc8db5ba9e.zip
Removed Class Eval and used define_method instead for the SafeBuffer
Diffstat (limited to 'activesupport/lib/active_support/core_ext/string')
-rw-r--r--activesupport/lib/active_support/core_ext/string/output_safety.rb21
1 files changed, 9 insertions, 12 deletions
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 dc033ed11b..c368e7f505 100644
--- a/activesupport/lib/active_support/core_ext/string/output_safety.rb
+++ b/activesupport/lib/active_support/core_ext/string/output_safety.rb
@@ -171,18 +171,15 @@ module ActiveSupport #:nodoc:
end
UNSAFE_STRING_METHODS.each do |unsafe_method|
- if 'String'.respond_to?(unsafe_method)
- class_eval <<-EOT, __FILE__, __LINE__ + 1
- def #{unsafe_method}(*args, &block) # def capitalize(*args, &block)
- to_str.#{unsafe_method}(*args, &block) # to_str.capitalize(*args, &block)
- end # end
-
- def #{unsafe_method}!(*args) # def capitalize!(*args)
- @html_safe = false # @html_safe = false
- super # super
- end # end
- EOT
- end
+ if String.new.respond_to?(unsafe_method)
+ define_method(unsafe_method.to_sym) do |*args, &block|
+ to_str.send(unsafe_method, *args, &block)
+ end
+ define_method("#{unsafe_method}!".to_sym) do |*args|
+ @html_safe = false
+ super(*args)
+ end
+ end
end
end
end