Class: Ratalada::Request
- Inherits:
-
Object
- Object
- Ratalada::Request
- Defined in:
- lib/ratalada.rb
Overview
Wraps the Rack env with just enough sugar to pattern match on.
Instance Attribute Summary collapse
-
#env ⇒ Object
readonly
Returns the value of attribute env.
Instance Method Summary collapse
- #body ⇒ Object
-
#deconstruct ⇒ Object
Enables
in ["GET", "/"]. -
#deconstruct_keys(_keys) ⇒ Object
Enables
in {verb: "GET", path: "/users"}. -
#initialize(env) ⇒ Request
constructor
A new instance of Request.
- #path ⇒ Object
- #query ⇒ Object
- #verb ⇒ Object
Constructor Details
#initialize(env) ⇒ Request
Returns a new instance of Request.
42 43 44 |
# File 'lib/ratalada.rb', line 42 def initialize(env) @env = env end |
Instance Attribute Details
#env ⇒ Object (readonly)
Returns the value of attribute env.
40 41 42 |
# File 'lib/ratalada.rb', line 40 def env @env end |
Instance Method Details
#body ⇒ Object
49 |
# File 'lib/ratalada.rb', line 49 def body = @body ||= env["rack.input"]&.read |
#deconstruct ⇒ Object
Enables in ["GET", "/"]
52 |
# File 'lib/ratalada.rb', line 52 def deconstruct = [verb, path] |
#deconstruct_keys(_keys) ⇒ Object
Enables in {verb: "GET", path: "/users"}
55 |
# File 'lib/ratalada.rb', line 55 def deconstruct_keys(_keys) = { verb:, path:, query:, env: } |
#path ⇒ Object
47 |
# File 'lib/ratalada.rb', line 47 def path = env["PATH_INFO"] |
#query ⇒ Object
48 |
# File 'lib/ratalada.rb', line 48 def query = env["QUERY_STRING"] |
#verb ⇒ Object
46 |
# File 'lib/ratalada.rb', line 46 def verb = env["REQUEST_METHOD"] |