Class: Lotus::View::Rendering::Scope
- Inherits:
-
LayoutScope
- Object
- LayoutScope
- Lotus::View::Rendering::Scope
- Defined in:
- lib/lotus/view/rendering/scope.rb
Overview
Rendering scope
Instance Method Summary collapse
-
#format ⇒ Symbol
Returns the requested format.
-
#initialize(view, locals = {}) ⇒ Scope
constructor
private
Initialize the scope.
-
#inspect ⇒ String
Returns an inspect String.
-
#respond_to_missing?(m, include_all) ⇒ TrueClass, FalseClass
private
Implements “respond to” logic.
Methods inherited from LayoutScope
#class, #content, #locals, #render, #respond_to?, #view
Constructor Details
#initialize(view, locals = {}) ⇒ Scope
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initialize the scope
23 24 25 |
# File 'lib/lotus/view/rendering/scope.rb', line 23 def initialize(view, locals = {}) @view, @locals, @layout = view, locals, layout end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &block) ⇒ Object (protected)
62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/lotus/view/rendering/scope.rb', line 62 def method_missing(m, *args, &block) ::Lotus::View::Escape.html( if @view.respond_to?(m) @view.__send__ m, *args, &block elsif @locals.key?(m) @locals[m] else super end ) end |
Instance Method Details
#format ⇒ Symbol
Returns the requested format.
44 45 46 |
# File 'lib/lotus/view/rendering/scope.rb', line 44 def format locals[:format] end |
#inspect ⇒ String
Returns an inspect String
32 33 34 35 36 37 |
# File 'lib/lotus/view/rendering/scope.rb', line 32 def inspect base = "#<#{ self.class }: #{'%x' % (self.object_id << 1)}" base << " @view=\"#{@view}\"" if @view base << " @locals=\"#{@locals}\"" if @locals base << ">" end |
#respond_to_missing?(m, include_all) ⇒ TrueClass, FalseClass
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Implements “respond to” logic
56 57 58 59 |
# File 'lib/lotus/view/rendering/scope.rb', line 56 def respond_to_missing?(m, include_all) @view.respond_to?(m) || @locals.key?(m) end |