Class: Reynard::RequestContext

Inherits:
Struct
  • Object
show all
Defined in:
lib/reynard/request_context.rb

Overview

Value class for details about the request.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#base_urlObject

Returns the value of attribute base_url

Returns:

  • (Object)

    the current value of base_url



5
6
7
# File 'lib/reynard/request_context.rb', line 5

def base_url
  @base_url
end

#bodyObject

Returns the value of attribute body

Returns:

  • (Object)

    the current value of body



5
6
7
# File 'lib/reynard/request_context.rb', line 5

def body
  @body
end

#headersObject

Returns the value of attribute headers

Returns:

  • (Object)

    the current value of headers



5
6
7
# File 'lib/reynard/request_context.rb', line 5

def headers
  @headers
end

#loggerObject

Returns the value of attribute logger

Returns:

  • (Object)

    the current value of logger



5
6
7
# File 'lib/reynard/request_context.rb', line 5

def logger
  @logger
end

#operationObject

Returns the value of attribute operation

Returns:

  • (Object)

    the current value of operation



5
6
7
# File 'lib/reynard/request_context.rb', line 5

def operation
  @operation
end

#paramsObject

Returns the value of attribute params

Returns:

  • (Object)

    the current value of params



5
6
7
# File 'lib/reynard/request_context.rb', line 5

def params
  @params
end

Instance Method Details

#copy(**properties) ⇒ Object



38
39
40
41
42
# File 'lib/reynard/request_context.rb', line 38

def copy(**properties)
  copy = dup
  properties.each { |attribute, value| copy.send("#{attribute}=", value) }
  copy
end

#full_pathObject



28
29
30
# File 'lib/reynard/request_context.rb', line 28

def full_path
  query_params? ? "#{path}?#{query}" : path
end

#pathObject



22
23
24
25
26
# File 'lib/reynard/request_context.rb', line 22

def path
  return unless operation&.path

  Template.new(operation.path, params ? params.fetch('path', {}) : {}).result
end

#queryObject



18
19
20
# File 'lib/reynard/request_context.rb', line 18

def query
  Rack::Utils.build_query(params['query']) if query_params?
end

#urlObject



32
33
34
35
36
# File 'lib/reynard/request_context.rb', line 32

def url
  return unless base_url

  "#{base_url}#{full_path}"
end

#verbObject



14
15
16
# File 'lib/reynard/request_context.rb', line 14

def verb
  operation&.verb
end