Class: Wee::Renderer
Overview
Base class of all Renderer classes.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#callbacks ⇒ Object
Returns the value of attribute callbacks.
-
#current_component ⇒ Object
Returns the value of attribute current_component.
-
#document ⇒ Object
Returns the value of attribute document.
-
#request ⇒ Object
Returns the value of attribute request.
-
#response ⇒ Object
Returns the value of attribute response.
-
#session ⇒ Object
Returns the value of attribute session.
Instance Method Summary collapse
-
#close ⇒ Object
Subclass responsibility.
-
#initialize(session = nil, request = nil, response = nil, callbacks = nil, document = nil, current_component = nil) ⇒ Renderer
constructor
A new instance of Renderer.
- #render(component) ⇒ Object
- #render_decoration(decoration) ⇒ Object
- #with(component) ⇒ Object
Constructor Details
#initialize(session = nil, request = nil, response = nil, callbacks = nil, document = nil, current_component = nil) ⇒ Renderer
Returns a new instance of Renderer.
14 15 16 17 18 19 20 21 |
# File 'lib/wee/renderer.rb', line 14 def initialize(session=nil, request=nil, response=nil, callbacks=nil, document=nil, current_component=nil) @session = session @request = request @response = response @callbacks = callbacks @document = document @current_component = current_component end |
Instance Attribute Details
#callbacks ⇒ Object
Returns the value of attribute callbacks.
10 11 12 |
# File 'lib/wee/renderer.rb', line 10 def callbacks @callbacks end |
#current_component ⇒ Object
Returns the value of attribute current_component.
12 13 14 |
# File 'lib/wee/renderer.rb', line 12 def current_component @current_component end |
#document ⇒ Object
Returns the value of attribute document.
11 12 13 |
# File 'lib/wee/renderer.rb', line 11 def document @document end |
#request ⇒ Object
Returns the value of attribute request.
8 9 10 |
# File 'lib/wee/renderer.rb', line 8 def request @request end |
#response ⇒ Object
Returns the value of attribute response.
9 10 11 |
# File 'lib/wee/renderer.rb', line 9 def response @response end |
#session ⇒ Object
Returns the value of attribute session.
7 8 9 |
# File 'lib/wee/renderer.rb', line 7 def session @session end |
Instance Method Details
#render(component) ⇒ Object
45 46 47 48 49 |
# File 'lib/wee/renderer.rb', line 45 def render(component) close component.decoration.render_on(self) nil end |
#render_decoration(decoration) ⇒ Object
51 52 53 54 55 |
# File 'lib/wee/renderer.rb', line 51 def render_decoration(decoration) close decoration.render_on(self) nil end |
#with(component) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/wee/renderer.rb', line 23 def with(component) rclass = component.renderer_class if rclass == self # reuse renderer old_component = @current_component begin @current_component = component yield self ensure @current_component = old_component end else close r = rclass.new(@session, @request, @response, @callbacks, @document, component) begin yield r ensure r.close end end end |