Class: Ratalada::Request

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

Overview

Wraps the Rack env with just enough sugar to pattern match on.

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#envObject (readonly)

Returns the value of attribute env.



40
41
42
# File 'lib/ratalada.rb', line 40

def env
  @env
end

Instance Method Details

#bodyObject



49
# File 'lib/ratalada.rb', line 49

def body  = @body ||= env["rack.input"]&.read

#deconstructObject

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: }

#pathObject



47
# File 'lib/ratalada.rb', line 47

def path  = env["PATH_INFO"]

#queryObject



48
# File 'lib/ratalada.rb', line 48

def query = env["QUERY_STRING"]

#verbObject



46
# File 'lib/ratalada.rb', line 46

def verb  = env["REQUEST_METHOD"]