aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext
diff options
context:
space:
mode:
authorShugo Maeda <shugo@ruby-lang.org>2018-11-08 23:28:40 +0900
committerShugo Maeda <shugo@ruby-lang.org>2018-11-08 23:28:40 +0900
commit94ac3f782027c4b707470b1aa0f5f66c6702ad9f (patch)
tree271dded9df39418f2bb083028fb9d71f5f4d310e /activesupport/lib/active_support/core_ext
parent3891c725ade96b7a847ac133496ad307bd05e920 (diff)
downloadrails-94ac3f782027c4b707470b1aa0f5f66c6702ad9f.tar.gz
rails-94ac3f782027c4b707470b1aa0f5f66c6702ad9f.tar.bz2
rails-94ac3f782027c4b707470b1aa0f5f66c6702ad9f.zip
Add a commented code example of what will be produced
Diffstat (limited to 'activesupport/lib/active_support/core_ext')
-rw-r--r--activesupport/lib/active_support/core_ext/string/output_safety.rb44
1 files changed, 22 insertions, 22 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 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