Class: Hanami::RenderingPolicy Private

Inherits:
Object
  • Object
show all
Defined in:
lib/hanami/rendering_policy.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Rendering policy

Since:

  • 0.1.0

Constant Summary collapse

STATUS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0

0
HEADERS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0

1
BODY =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0

2
HANAMI_ACTION =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0

'hanami.action'.freeze
RACK_EXCEPTION =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0

'rack.exception'.freeze
SUCCESSFUL_STATUSES =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0

(200..201).freeze
RENDERABLE_FORMATS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0

[:all, :html].freeze
ERROR_STATUS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Since:

  • 0.1.0

500

Instance Method Summary collapse

Constructor Details

#initialize(configuration) ⇒ RenderingPolicy

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.

Returns a new instance of RenderingPolicy.

Since:

  • 0.1.0



31
32
33
34
# File 'lib/hanami/rendering_policy.rb', line 31

def initialize(configuration)
  @controller_pattern = %r{#{ configuration.controller_pattern.gsub(/\%\{(controller|action)\}/) { "(?<#{ $1 }>(.*))" } }}
  @configuration = configuration
end

Instance Method Details

#render(env, response) ⇒ Object

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



37
38
39
40
41
42
# File 'lib/hanami/rendering_policy.rb', line 37

def render(env, response)
  body = _render(env, response)

  response[BODY] = Array(body) unless body.nil? || body.respond_to?(:each)
  response
end