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 html_safe?: () -> untyped
  def initialize: (?(ActionView::OutputBuffer | String) str) -> void
  def to_s: () -> untyped
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
    new_safe_buffer = new_string.is_a?(SafeBuffer) ? new_string : SafeBuffer.new(new_string)
    new_safe_buffer.instance_variable_set :@html_safe, true
    new_safe_buffer
  else
    to_str[*args]
  end
end

def []=(*args)

def []=(*args)
  if args.length == 3
    super(args[0], args[1], implicit_html_escape_interpolated_argument(args[2]))
  else
    super(args[0], implicit_html_escape_interpolated_argument(args[1]))
  end
end

def bytesplice(*args, value)

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

def clone_empty

def clone_empty
  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 html_safe?

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

def html_safe?: () -> untyped

This signature was generated using 3 samples from 1 application.

def html_safe?
  defined?(@html_safe) && @html_safe
end

def implicit_html_escape_interpolated_argument(arg)

def implicit_html_escape_interpolated_argument(arg)
  if !html_safe? || arg.html_safe?
    arg
  else
    arg_string = begin
      arg.to_str
    rescue NoMethodError => error
      if error.name == :to_str
        str = arg.to_s
        ActiveSupport::Deprecation.warn <<~MSG.squish
          Implicit conversion of #{arg.class} into String by ActiveSupport::SafeBuffer
          is deprecated and will be removed in Rails 7.1.
          You must explicitly cast it to a String.
        MSG
        str
      else
        raise
      end
    end
    CGI.escapeHTML(arg_string)
  end
end

def initialize(str = "")

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

def initialize: (?(ActionView::OutputBuffer | String) str) -> void

This signature was generated using 5 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 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: () -> untyped

This signature was generated using 2 samples from 1 application.

def to_s
  self
end