Class: Hanami::View::Rendering::Scope

Inherits:
LayoutScope show all
Defined in:
gems/gems/hanami-view-1.3.0/lib/hanami/view/rendering/scope.rb

Overview

Rendering view scope

See Also:

Since:

  • 0.1.0

Instance Method Summary collapse

Methods inherited from LayoutScope

#class, #local, #locals, #render, #view

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args, &block) ⇒ Object (protected)

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.

Since:

  • 0.1.0

def method_missing(m, *args, &block)
  ::Hanami::View::Escape.html(
    # FIXME: this isn't compatible with Hanami 2.0, as it extends a view
    # that we want to be frozen in the future
    #
    # See https://github.com/hanami/view/issues/130#issuecomment-319326236
    if @view.respond_to?(m, true)
      @view.__send__ m, *args, &block
    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

def format
  locals[:format]
end

#inspectString

Returns an inspect String

Returns:

  • (String)

    inspect String (contains classname, objectid in hex, available ivars)

Since:

  • 0.3.0

def inspect
  base = "#<#{ self.class }: #{'%x' % (self.object_id << 1)}"
  base << " @view=\"#{@view}\"" if @view
  base << " @locals=\"#{@locals}\"" if @locals
  base << ">"
end