From 71b95bd954edd8e8f09293044d49b34b9120279a Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Mon, 13 Feb 2012 17:54:58 +0900 Subject: add AS::SafeBuffer#clone_empty --- activesupport/lib/active_support/core_ext/string/output_safety.rb | 6 ++++++ 1 file changed, 6 insertions(+) (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 dd780da157..20c2befc57 100644 --- a/activesupport/lib/active_support/core_ext/string/output_safety.rb +++ b/activesupport/lib/active_support/core_ext/string/output_safety.rb @@ -124,6 +124,12 @@ module ActiveSupport #:nodoc: @dirty = other.dirty? end + def clone_empty + new_safe_buffer = self[0, 0] + new_safe_buffer.instance_variable_set(:@dirty, @dirty) + new_safe_buffer + end + def concat(value) if dirty? || value.html_safe? super(value) -- cgit v1.2.3