Class: Lotus::View::Rendering::Scope

Inherits:
LayoutScope show all
Defined in:
lib/lotus/view/rendering/scope.rb

Overview

Rendering scope

See Also:

Since:

  • 0.1.0

Instance Method Summary collapse

Methods inherited from LayoutScope

#locals, #render, #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

Parameters:

  • view (Class)

    the view

  • locals (Hash) (defaults to: {})

    a set of objects available during the rendering

Options Hash (locals):

  • :format (Symbol)

    the requested format

Since:

  • 0.1.0



22
23
24
# File 'lib/lotus/view/rendering/scope.rb', line 22

def initialize(view, locals = {})
  @view, @locals = view, locals
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m) ⇒ Object (protected)

Since:

  • 0.1.0



36
37
38
39
40
41
42
43
44
# File 'lib/lotus/view/rendering/scope.rb', line 36

def method_missing(m)
  if @view.respond_to?(m)
    @view.__send__ m
  elsif @locals.key?(m)
    @locals[m]
  else
    super
  end
end

Instance Method Details

#formatSymbol

Returns the requested format.

Returns:

  • (Symbol)

    the requested format (eg. :html, :json, :xml, etc..)

Since:

  • 0.1.0



31
32
33
# File 'lib/lotus/view/rendering/scope.rb', line 31

def format
  locals[:format]
end