Class: Sidewalk::TemplateHandlers::BaseDelegate
- Inherits:
-
Object
- Object
- Sidewalk::TemplateHandlers::BaseDelegate
- Defined in:
- lib/sidewalk/template_handlers/base_delegate.rb
Overview
A delegate scope to run templates in.
Used to provide templates access to the controller’s instance variables, and extra helper functions, without polluting the controller with them. For example, ErbHandler::Delegate will also include the standard ERB::Util
helper functions like #h
(aka #html_escape
)
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(controller) ⇒ BaseDelegate
constructor
A new instance of delegate.
-
#render ⇒ Object
Render the template in the scope.
Constructor Details
#initialize(controller) ⇒ BaseDelegate
A new instance of delegate.
Copies all instance variables from controller to object.
16 17 18 19 20 21 22 23 |
# File 'lib/sidewalk/template_handlers/base_delegate.rb', line 16 def initialize controller controller.instance_variables.each do |name| self.instance_variable_set( name, controller.instance_variable_get(name) ) end end |
Instance Method Details
#render ⇒ Object
Render the template in the scope.
The default implementation raises a NotImplementedError.
34 35 36 |
# File 'lib/sidewalk/template_handlers/base_delegate.rb', line 34 def render raise NotImplementedError.new end |