Class: ActionView::StreamingFlow
- Inherits:
-
OutputFlow
- Object
- OutputFlow
- ActionView::StreamingFlow
- Defined in:
- lib/action_view/flows.rb
Overview
:nodoc:
Instance Attribute Summary
Attributes inherited from OutputFlow
Instance Method Summary collapse
-
#append!(key, value) ⇒ Object
Appends the contents for the given key.
-
#get(key) ⇒ Object
Try to get stored content.
-
#initialize(view, fiber) ⇒ StreamingFlow
constructor
A new instance of StreamingFlow.
Methods inherited from OutputFlow
Constructor Details
#initialize(view, fiber) ⇒ StreamingFlow
Returns a new instance of StreamingFlow.
30 31 32 33 34 35 36 37 |
# File 'lib/action_view/flows.rb', line 30 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 Method Details
#append!(key, value) ⇒ Object
Appends the contents for the given key. This is called by provides and resumes back to the fiber if it is the key it is waiting for.
65 66 67 68 |
# File 'lib/action_view/flows.rb', line 65 def append!(key, value) super @fiber.resume if @waiting_for == key end |
#get(key) ⇒ Object
Try to get stored content. If the content is not available and we are inside the layout fiber, we set that we are waiting for the given key and yield.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File '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 |