Class: Hanami::RenderingPolicy Private
- Inherits:
-
Object
- Object
- Hanami::RenderingPolicy
- 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
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.
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.
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.
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.
'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.
'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.
(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.
[: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.
500
Instance Method Summary collapse
-
#initialize(configuration) ⇒ RenderingPolicy
constructor
private
A new instance of RenderingPolicy.
- #render(env, response) ⇒ Object private
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.
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.
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 |