Class: Hanami::Router::Block::Context Private
- Inherits:
-
Object
- Object
- Hanami::Router::Block::Context
- Defined in:
- lib/hanami/router/block.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.
Context to handle a single incoming HTTP request for a block endpoint
Instance Attribute Summary collapse
-
#env ⇒ Hash
readonly
private
Rack env.
Instance Method Summary collapse
- #call ⇒ Object private
- #headers(value = nil) ⇒ Object private
-
#initialize(blk, env) ⇒ Context
constructor
private
A new instance of Context.
-
#params ⇒ Hash
private
HTTP Params from URL variables and HTTP body parsing.
- #status(value = nil) ⇒ Object private
Constructor Details
#initialize(blk, env) ⇒ Context
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 Context.
16 17 18 19 |
# File 'lib/hanami/router/block.rb', line 16 def initialize(blk, env) @blk = blk @env = env end |
Instance Attribute Details
#env ⇒ Hash (readonly)
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.
Rack env
26 27 28 |
# File 'lib/hanami/router/block.rb', line 26 def env @env end |
Instance Method Details
#call ⇒ 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.
67 68 69 70 |
# File 'lib/hanami/router/block.rb', line 67 def call body = instance_exec(&@blk) [status, headers, [body]] end |
#headers ⇒ Integer #headers(value) ⇒ 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.
48 49 50 51 52 53 54 |
# File 'lib/hanami/router/block.rb', line 48 def headers(value = nil) if value @headers = value else @headers ||= {} end end |
#params ⇒ Hash
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.
HTTP Params from URL variables and HTTP body parsing
61 62 63 |
# File 'lib/hanami/router/block.rb', line 61 def params env[Router::PARAMS] end |
#status ⇒ Integer #status(value) ⇒ 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.
34 35 36 37 38 39 40 |
# File 'lib/hanami/router/block.rb', line 34 def status(value = nil) if value @status = value else @status ||= Router::HTTP_STATUS_OK end end |