Module: Waves::Views::Mixin
- Includes:
- ResponseMixin
- Defined in:
- lib/views/mixin.rb
Overview
The View mixin simply sets up the machinery for invoking a template, along with methods for accessing the request context and the standard interface for invoking a view method.
Instance Attribute Summary collapse
-
#request ⇒ Object
readonly
Returns the value of attribute request.
Class Method Summary collapse
Instance Method Summary collapse
- #initialize(request) ⇒ Object
- #method_missing(name, *args) ⇒ Object
- #render(path, context = {}) ⇒ Object
- #renderer(path) ⇒ Object
Methods included from ResponseMixin
#controllers, #domain, #log, #models, #not_found, #params, #path, #redirect, #response, #session, #url, #views
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
100 101 102 |
# File 'lib/views/mixin.rb', line 100 def method_missing(name,*args) render( "/#{self.class.basename.snake_case}/#{name}", *args ) end |
Instance Attribute Details
#request ⇒ Object (readonly)
Returns the value of attribute request.
72 73 74 |
# File 'lib/views/mixin.rb', line 72 def request @request end |
Class Method Details
.included(c) ⇒ Object
76 77 78 79 80 |
# File 'lib/views/mixin.rb', line 76 def self.included( c ) def c.process( request, *args, &block ) self.new( request ).instance_exec( *args, &block ) end end |
Instance Method Details
#initialize(request) ⇒ Object
82 83 84 85 |
# File 'lib/views/mixin.rb', line 82 def initialize( request ) @request = request @layout = :default end |
#render(path, context = {}) ⇒ Object
93 94 95 96 97 98 |
# File 'lib/views/mixin.rb', line 93 def render( path, context = {} ) context.merge!( :request => request ) template = renderer( path ) || renderer( :generic / File.basename(path) ) raise NoTemplateError.new( path ) if template.nil? template.render( path, context ) end |