Module: ActionView::Context

Included in:
Base, TestCase::Behavior
Defined in:
actionview/lib/action_view/context.rb

Overview

Action View Context

Action View contexts are supplied to Action Controller to render a template. The default Action View context is ActionView::Base.

In order to work with Action Controller, a Context must just include this module. The initialization of the variables used by the context (@output_buffer, @view_flow, and @virtual_path) is responsibility of the object that includes this module (although you can call _prepare_context defined below).

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#output_bufferObject

Returns the value of attribute output_buffer



15
16
17
# File 'actionview/lib/action_view/context.rb', line 15

def output_buffer
  @output_buffer
end

#view_flowObject

Returns the value of attribute view_flow



15
16
17
# File 'actionview/lib/action_view/context.rb', line 15

def view_flow
  @view_flow
end

Instance Method Details

#_layout_for(name = nil) ⇒ Object

Encapsulates the interaction with the view flow so it returns the correct buffer on yield. This is usually overwritten by helpers to add more behavior.



27
28
29
30
# File 'actionview/lib/action_view/context.rb', line 27

def _layout_for(name = nil)
  name ||= :layout
  view_flow.get(name).html_safe
end

#_prepare_contextObject

Prepares the context by setting the appropriate instance variables.



18
19
20
21
22
# File 'actionview/lib/action_view/context.rb', line 18

def _prepare_context
  @view_flow     = OutputFlow.new
  @output_buffer = nil
  @virtual_path  = nil
end