From 94ac3f782027c4b707470b1aa0f5f66c6702ad9f Mon Sep 17 00:00:00 2001 From: Shugo Maeda Date: Thu, 8 Nov 2018 23:28:40 +0900 Subject: Add a commented code example of what will be produced --- .../core_ext/string/output_safety.rb | 44 +++++++++++----------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'activesupport/lib/active_support/core_ext') 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 e3f62d7d26..c27d7bbc78 100644 --- a/activesupport/lib/active_support/core_ext/string/output_safety.rb +++ b/activesupport/lib/active_support/core_ext/string/output_safety.rb @@ -254,28 +254,28 @@ module ActiveSupport #:nodoc: UNSAFE_STRING_METHODS_WITH_BACKREF.each do |unsafe_method| if unsafe_method.respond_to?(unsafe_method) class_eval <<-EOT, __FILE__, __LINE__ + 1 - def #{unsafe_method}(*args, &block) - if block - to_str.#{unsafe_method}(*args) { |*params| - set_block_back_references(block, $~) - block.call(*params) - } - else - to_str.#{unsafe_method}(*args) - end - end - - def #{unsafe_method}!(*args, &block) - @html_safe = false - if block - super(*args) { |*params| - set_block_back_references(block, $~) - block.call(*params) - } - else - super - end - end + def #{unsafe_method}(*args, &block) # def gsub(*args, &block) + if block # if block + to_str.#{unsafe_method}(*args) { |*params| # to_str.gsub(*args) { |*params| + set_block_back_references(block, $~) # set_block_back_references(block, $~) + block.call(*params) # block.call(*params) + } # } + else # else + to_str.#{unsafe_method}(*args) # to_str.gsub(*args) + end # end + end # end + + def #{unsafe_method}!(*args, &block) # def gsub!(*args, &block) + @html_safe = false # @html_safe = false + if block # if block + super(*args) { |*params| # super(*args) { |*params| + set_block_back_references(block, $~) # set_block_back_references(block, $~) + block.call(*params) # block.call(*params) + } # } + else # else + super # super + end # end + end # end EOT end end -- cgit v1.2.3