class ActiveSupport::SafeBuffer

Experimental RBS support (using type sampling data from the type_fusion project).

# sig/active_support/core_ext/string/output_safety.rbs

class ActiveSupport::SafeBuffer < ActiveSupport::String
  def initialize: (?(String | ActiveSupport::SafeBuffer) str) -> void
  def to_s: () -> ActiveSupport::SafeBuffer
end

:nodoc:

def %(args)

def %(args)
  case args
  when Hash
    escaped_args = args.transform_values { |arg| explicit_html_escape_interpolated_argument(arg) }
  else
    escaped_args = Array(args).map { |arg| explicit_html_escape_interpolated_argument(arg) }
  end
  self.class.new(super(escaped_args))
end

def *(_)

def *(_)
  new_string = super
  new_safe_buffer = new_string.is_a?(SafeBuffer) ? new_string : SafeBuffer.new(new_string)
  new_safe_buffer.instance_variable_set(:@html_safe, @html_safe)
  new_safe_buffer
end

def +(other)

def +(other)
  dup.concat(other)
end

def [](*args)

def [](*args)
  if html_safe?
    new_string = super
    return unless new_string
    string_into_safe_buffer(new_string, true)
  else
    to_str[*args]
  end
end

def []=(arg1, arg2, arg3 = nil)

def []=(arg1, arg2, arg3 = nil)
  if arg3
    super(arg1, arg2, implicit_html_escape_interpolated_argument(arg3))
  else
    super(arg1, implicit_html_escape_interpolated_argument(arg2))
  end
end

def bytesplice(*args, value)

def bytesplice(*args, value)
  super(*args, implicit_html_escape_interpolated_argument(value))
end

def chr

def chr
  return super unless html_safe?
  string_into_safe_buffer(super, true)
end

def clone_empty # :nodoc:

:nodoc:
def clone_empty # :nodoc:
  ActiveSupport.deprecator.warn <<~EOM
    ActiveSupport::SafeBuffer#clone_empty is deprecated and will be removed in Rails 7.2.
  EOM
  self[0, 0]
end

def concat(value)

def concat(value)
  unless value.nil?
    super(implicit_html_escape_interpolated_argument(value))
  end
  self
end

def encode_with(coder)

def encode_with(coder)
  coder.represent_object nil, to_str
end

def explicit_html_escape_interpolated_argument(arg)

def explicit_html_escape_interpolated_argument(arg)
  (!html_safe? || arg.html_safe?) ? arg : CGI.escapeHTML(arg.to_s)
end

def implicit_html_escape_interpolated_argument(arg)

def implicit_html_escape_interpolated_argument(arg)
  if !html_safe? || arg.html_safe?
    arg
  else
    CGI.escapeHTML(arg.to_str)
  end
end

def initialize(str = "")

Experimental RBS support (using type sampling data from the type_fusion project).

def initialize: (?(String | ActiveSupport::SafeBuffer) str) -> void

This signature was generated using 8 samples from 1 application.

def initialize(str = "")
  @html_safe = true
  super
end

def initialize_copy(other)

def initialize_copy(other)
  super
  @html_safe = other.html_safe?
end

def insert(index, value)

def insert(index, value)
  super(index, implicit_html_escape_interpolated_argument(value))
end

def prepend(value)

def prepend(value)
  super(implicit_html_escape_interpolated_argument(value))
end

def replace(value)

def replace(value)
  super(implicit_html_escape_interpolated_argument(value))
end

def safe_concat(value)

def safe_concat(value)
  raise SafeConcatError unless html_safe?
  original_concat(value)
end

def set_block_back_references(block, match_data)

def set_block_back_references(block, match_data)
  block.binding.eval("proc { |m| $~ = m }").call(match_data)
rescue ArgumentError
  # Can't create binding from C level Proc
end

def slice!(*args)

def slice!(*args)
  new_string = super
  return new_string if !html_safe? || new_string.nil?
  string_into_safe_buffer(new_string, true)
end

def string_into_safe_buffer(new_string, is_html_safe)

def string_into_safe_buffer(new_string, is_html_safe)
  new_safe_buffer = new_string.is_a?(SafeBuffer) ? new_string : SafeBuffer.new(new_string)
  new_safe_buffer.instance_variable_set :@html_safe, is_html_safe
  new_safe_buffer
end

def to_param

def to_param
  to_str
end

def to_s

Experimental RBS support (using type sampling data from the type_fusion project).

def to_s: () -> ActiveSupport::SafeBuffer

This signature was generated using 4 samples from 1 application.

def to_s
  self
end