Class: ActiveSupport::SafeBuffer

Inherits:
String show all
Defined in:
lib/active_support/core_ext/string/output_safety.rb

Constant Summary collapse

UNSAFE_STRING_METHODS =
["capitalize", "chomp", "chop", "delete", "downcase", "gsub", "lstrip", "next", "reverse", "rstrip", "slice", "squeeze", "strip", "sub", "succ", "swapcase", "tr", "tr_s", "upcase"].freeze

Instance Method Summary collapse

Methods inherited from String

#acts_like_string?, #as_json, #at, #blank?, #camelize, #classify, #constantize, #dasherize, #demodulize, #encode_json, #encoding_aware?, #exclude?, #first, #foreign_key, #from, #html_safe!, #humanize, #is_utf8?, #last, #mb_chars, #ord, #parameterize, #pluralize, #singularize, #squish, #squish!, #strip_heredoc, #tableize, #titleize, #to, #to_date, #to_datetime, #to_time, #truncate, #underscore

Instance Method Details

#+(other) ⇒ Object



88
89
90
# File 'lib/active_support/core_ext/string/output_safety.rb', line 88

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

#concat(value) ⇒ Object Also known as: <<



79
80
81
82
83
84
85
# File 'lib/active_support/core_ext/string/output_safety.rb', line 79

def concat(value)
  if value.html_safe?
    super(value)
  else
    super(ERB::Util.h(value))
  end
end

#html_safeObject



96
97
98
# File 'lib/active_support/core_ext/string/output_safety.rb', line 96

def html_safe
  self
end

#html_safe?Boolean

Returns:

  • (Boolean)


92
93
94
# File 'lib/active_support/core_ext/string/output_safety.rb', line 92

def html_safe?
  true
end

#safe_concatObject



77
# File 'lib/active_support/core_ext/string/output_safety.rb', line 77

alias safe_concat concat

#to_sObject



100
101
102
# File 'lib/active_support/core_ext/string/output_safety.rb', line 100

def to_s
  self
end

#to_yaml(*args) ⇒ Object



104
105
106
# File 'lib/active_support/core_ext/string/output_safety.rb', line 104

def to_yaml(*args)
  to_str.to_yaml(*args)
end