123456789_123456789_123456789_123456789_123456789_

Class: ActionView::StreamingBuffer

Do not use. This class is for internal use only.
Relationships & Source Files
Inherits: Object
Defined in: actionview/lib/action_view/buffers.rb

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(block) ⇒ StreamingBuffer

[ GitHub ]

  
# File 'actionview/lib/action_view/buffers.rb', line 109

def initialize(block)
  @block = block
end

Instance Attribute Details

#append=(value) (writeonly)

Alias for #<<.

[ GitHub ]

  
# File 'actionview/lib/action_view/buffers.rb', line 119

alias :append= :<<

#block (readonly)

[ GitHub ]

  
# File 'actionview/lib/action_view/buffers.rb', line 147

attr_reader :block

#html_safe?Boolean (readonly)

[ GitHub ]

  
# File 'actionview/lib/action_view/buffers.rb', line 135

def html_safe?
  true
end

#safe_append=(value) (writeonly)

Alias for #safe_concat.

[ GitHub ]

  
# File 'actionview/lib/action_view/buffers.rb', line 124

alias :safe_append= :safe_concat

Instance Method Details

#<<(value) Also known as: #concat, #append=

[ GitHub ]

  
# File 'actionview/lib/action_view/buffers.rb', line 113

def <<(value)
  value = value.to_s
  value = ERB::Util.h(value) unless value.html_safe?
  @block.call(value)
end

#capture

[ GitHub ]

  
# File 'actionview/lib/action_view/buffers.rb', line 126

def capture
  buffer = +""
  old_block, @block = @block, ->(value) { buffer << value }
  yield
  buffer.html_safe
ensure
  @block = old_block
end

#concat(value)

Alias for #<<.

[ GitHub ]

  
# File 'actionview/lib/action_view/buffers.rb', line 118

alias :concat  :<<

#html_safe (readonly)

[ GitHub ]

  
# File 'actionview/lib/action_view/buffers.rb', line 139

def html_safe
  self
end

#raw

[ GitHub ]

  
# File 'actionview/lib/action_view/buffers.rb', line 143

def raw
  RawStreamingBuffer.new(self)
end

#safe_concat(value) Also known as: #safe_append=

[ GitHub ]

  
# File 'actionview/lib/action_view/buffers.rb', line 121

def safe_concat(value)
  @block.call(value.to_s)
end