Class: ActiveSupport::SafeBuffer

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

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



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

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

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



70
71
72
73
74
75
76
# File 'lib/active_support/core_ext/string/output_safety.rb', line 70

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

#html_safeObject



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

def html_safe
  self
end

#html_safe?Boolean

Returns:

  • (Boolean)


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

def html_safe?
  true
end

#safe_concatObject



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

alias safe_concat concat

#to_sObject



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

def to_s
  self
end

#to_yaml(*args) ⇒ Object



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

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