Class: ActionView::OutputBuffer

Inherits:
ActiveSupport::SafeBuffer show all
Defined in:
actionview/lib/action_view/buffers.rb

Overview

Used as a buffer for views

The main difference between this and ActiveSupport::SafeBuffer is for the methods ‘<<` and `safe_expr_append=` the inputs are checked for nil before they are assigned and `to_s` is called on the input. For example:

obuf = ActionView::OutputBuffer.new "hello"
obuf << 5
puts obuf # => "hello5"

sbuf = ActiveSupport::SafeBuffer.new "hello"
sbuf << 5
puts sbuf # => "hello\u0005"

Constant Summary

Constants inherited from ActiveSupport::SafeBuffer

ActiveSupport::SafeBuffer::UNSAFE_STRING_METHODS, ActiveSupport::SafeBuffer::UNSAFE_STRING_METHODS_WITH_BACKREF

Constants inherited from String

String::BLANK_RE, String::ENCODED_BLANKS

Instance Method Summary collapse

Methods inherited from ActiveSupport::SafeBuffer

#%, #*, #+, #[], #[]=, #clone_empty, #concat, #encode_with, #html_safe?, #initialize_copy, #insert, #prepend, #replace, #safe_concat, #to_param, #to_s

Methods inherited from String

#acts_like_string?, #as_json, #at, #blank?, #camelize, #classify, #constantize, #dasherize, #deconstantize, #demodulize, #exclude?, #first, #foreign_key, #from, #html_safe, #humanize, #in_time_zone, #indent, #indent!, #inquiry, #is_utf8?, #last, #mb_chars, #parameterize, #pluralize, #remove, #remove!, #safe_constantize, #singularize, #squish, #squish!, #strip_heredoc, #tableize, #titleize, #to, #to_date, #to_datetime, #to_time, #truncate, #truncate_bytes, #truncate_words, #underscore, #upcase_first

Constructor Details

#initializeOutputBuffer

:nodoc:



22
23
24
25
# File 'actionview/lib/action_view/buffers.rb', line 22

def initialize(*)
  super
  encode!
end

Instance Method Details

#<<(value) ⇒ Object Also known as: append=



27
28
29
30
# File 'actionview/lib/action_view/buffers.rb', line 27

def <<(value)
  return self if value.nil?
  super(value.to_s)
end

#safe_expr_append=(val) ⇒ Object



33
34
35
36
# File 'actionview/lib/action_view/buffers.rb', line 33

def safe_expr_append=(val)
  return self if val.nil?
  safe_concat val.to_s
end