Class: ActionView::StreamingBuffer
- Inherits:
-
Object
- Object
- ActionView::StreamingBuffer
- Defined in:
- lib/action_view/buffers.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
Instance Method Summary collapse
- #<<(value) ⇒ Object (also: #concat, #append=)
- #capture ⇒ Object
- #html_safe ⇒ Object
- #html_safe? ⇒ Boolean
-
#initialize(block) ⇒ StreamingBuffer
constructor
A new instance of StreamingBuffer.
- #raw ⇒ Object
- #safe_concat(value) ⇒ Object (also: #safe_append=)
Constructor Details
#initialize(block) ⇒ StreamingBuffer
Returns a new instance of StreamingBuffer.
109 110 111 |
# File 'lib/action_view/buffers.rb', line 109 def initialize(block) @block = block end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
147 148 149 |
# File 'lib/action_view/buffers.rb', line 147 def block @block end |
Instance Method Details
#<<(value) ⇒ Object Also known as: concat, append=
113 114 115 116 117 |
# File '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 ⇒ Object
126 127 128 129 130 131 132 133 |
# File '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 |
#html_safe ⇒ Object
139 140 141 |
# File 'lib/action_view/buffers.rb', line 139 def html_safe self end |
#html_safe? ⇒ Boolean
135 136 137 |
# File 'lib/action_view/buffers.rb', line 135 def html_safe? true end |
#raw ⇒ Object
143 144 145 |
# File 'lib/action_view/buffers.rb', line 143 def raw RawStreamingBuffer.new(self) end |
#safe_concat(value) ⇒ Object Also known as: safe_append=
121 122 123 |
# File 'lib/action_view/buffers.rb', line 121 def safe_concat(value) @block.call(value.to_s) end |