Class: ActionView::OutputBuffer
    Do not use.  This class is for internal use only.
  
| Relationships & Source Files | |
| Inherits: | Object | 
| 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"Class Method Summary
- .new(buffer = "") ⇒ OutputBuffer constructor
Instance Attribute Summary
- 
    
      #append=(value)  
    
    writeonly
    Alias for #<<. 
- #encoding readonly
- #force_encoding readonly
- 
    
      #html_safe  
    
    readonly
    Alias for #to_s. 
- #html_safe? ⇒ Boolean readonly
- #length readonly
- #raw_buffer readonly
- 
    
      #safe_append=(value)  
    
    writeonly
    Alias for #safe_concat. 
- #safe_expr_append=(val) writeonly
Instance Method Summary
- #<<(value) (also: #concat, #append=)
- #==(other)
- #blank? ⇒ Boolean
- #capture(*args)
- 
    
      #concat(value)  
    
    Alias for #<<. 
- #empty? ⇒ Boolean
- #encode!
- #initialize_copy(other)
- #raw
- #safe_concat(value) (also: #safe_append=)
- #to_s (also: #html_safe)
- #to_str
Constructor Details
    .new(buffer = "")  ⇒ OutputBuffer 
  
Instance Attribute Details
#append=(value) (writeonly)
Alias for #<<.
# File 'actionview/lib/action_view/buffers.rb', line 54
alias :append= :<<
#encoding (readonly)
[ GitHub ]# File 'actionview/lib/action_view/buffers.rb', line 27
delegate :length, :empty?, :blank?, :encoding, :encode!, :force_encoding, to: :@raw_buffer
#force_encoding (readonly)
[ GitHub ]#html_safe (readonly)
Alias for #to_s.
# File 'actionview/lib/action_view/buffers.rb', line 32
alias_method :html_safe, :to_s
    #html_safe?  ⇒ Boolean  (readonly)
  
  [ GitHub ]
# File 'actionview/lib/action_view/buffers.rb', line 38
def html_safe? true end
#length (readonly)
[ GitHub ]# File 'actionview/lib/action_view/buffers.rb', line 27
delegate :length, :empty?, :blank?, :encoding, :encode!, :force_encoding, to: :@raw_buffer
#raw_buffer (readonly)
[ GitHub ]# File 'actionview/lib/action_view/buffers.rb', line 89
attr_reader :raw_buffer
#safe_append=(value) (writeonly)
Alias for #safe_concat.
# File 'actionview/lib/action_view/buffers.rb', line 60
alias :safe_append= :safe_concat
#safe_expr_append=(val) (writeonly)
[ GitHub ]# File 'actionview/lib/action_view/buffers.rb', line 62
def safe_expr_append=(val) return self if val.nil? @raw_buffer << val.to_s self end
Instance Method Details
#<<(value) Also known as: #concat, #append=
[ GitHub ]# File 'actionview/lib/action_view/buffers.rb', line 42
def <<(value) unless value.nil? value = value.to_s @raw_buffer << if value.html_safe? value else CGI.escapeHTML(value) end end self end
#==(other)
[ GitHub ]# File 'actionview/lib/action_view/buffers.rb', line 81
def ==(other) other.class == self.class && @raw_buffer == other.to_str end
    #blank?  ⇒ Boolean 
  
# File 'actionview/lib/action_view/buffers.rb', line 27
delegate :length, :empty?, :blank?, :encoding, :encode!, :force_encoding, to: :@raw_buffer
#capture(*args)
[ GitHub ]# File 'actionview/lib/action_view/buffers.rb', line 72
def capture(*args) new_buffer = +"" old_buffer, @raw_buffer = @raw_buffer, new_buffer yield(*args) new_buffer.html_safe ensure @raw_buffer = old_buffer end
#concat(value)
Alias for #<<.
# File 'actionview/lib/action_view/buffers.rb', line 53
alias :concat :<<
    #empty?  ⇒ Boolean 
  
# File 'actionview/lib/action_view/buffers.rb', line 27
delegate :length, :empty?, :blank?, :encoding, :encode!, :force_encoding, to: :@raw_buffer
#encode!
[ GitHub ]# File 'actionview/lib/action_view/buffers.rb', line 27
delegate :length, :empty?, :blank?, :encoding, :encode!, :force_encoding, to: :@raw_buffer
#initialize_copy(other)
[ GitHub ]# File 'actionview/lib/action_view/buffers.rb', line 68
def initialize_copy(other) @raw_buffer = other.to_str end
#raw
[ GitHub ]# File 'actionview/lib/action_view/buffers.rb', line 85
def raw RawOutputBuffer.new(self) end
#safe_concat(value) Also known as: #safe_append=
[ GitHub ]# File 'actionview/lib/action_view/buffers.rb', line 56
def safe_concat(value) @raw_buffer << value self end
#to_s Also known as: #html_safe
[ GitHub ]# File 'actionview/lib/action_view/buffers.rb', line 29
def to_s @raw_buffer.html_safe end
#to_str
[ GitHub ]# File 'actionview/lib/action_view/buffers.rb', line 34
def to_str @raw_buffer.dup end