Class: ActionView::StreamingFlow
Do not use. This class is for internal use only.
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
OutputFlow
|
|
Instance Chain:
self,
OutputFlow
|
|
Inherits: |
ActionView::OutputFlow
|
Defined in: | actionview/lib/action_view/flows.rb |
Class Method Summary
Instance Attribute Summary
Instance Method Summary
-
#append!(key, value)
Appends the contents for the given key.
-
#get(key)
Try to get stored content.
OutputFlow
- Inherited
#append | Called by content_for. |
#append! | Alias for OutputFlow#append. |
#get | Called by _layout_for to read stored values. |
#set | Called by each renderer object to set the layout contents. |
Constructor Details
.new(view, fiber) ⇒ StreamingFlow
# File 'actionview/lib/action_view/flows.rb', line 31
def initialize(view, fiber) @view = view @parent = nil @child = view.output_buffer @content = view.view_flow.content @fiber = fiber @root = Fiber.current.object_id end
Instance Attribute Details
#inside_fiber? ⇒ Boolean
(readonly, private)
[ GitHub ]
# File 'actionview/lib/action_view/flows.rb', line 71
def inside_fiber? Fiber.current.object_id != @root end
Instance Method Details
#append!(key, value)
Appends the contents for the given key. This is called by providing and resuming back to the fiber, if that’s the key it’s waiting for.
# File 'actionview/lib/action_view/flows.rb', line 65
def append!(key, value) super @fiber.resume if @waiting_for == key end
#get(key)
Try to get stored content. If the content is not available and we’re inside the layout fiber, then it will begin waiting for the given key and yield.
# File 'actionview/lib/action_view/flows.rb', line 43
def get(key) return super if @content.key?(key) if inside_fiber? view = @view begin @waiting_for = key view.output_buffer, @parent = @child, view.output_buffer Fiber.yield ensure @waiting_for = nil view.output_buffer, @child = @parent, view.output_buffer end end super end