Class: Reynard::RequestContext
- Inherits:
-
Struct
- Object
- Struct
- Reynard::RequestContext
- Defined in:
- lib/reynard/request_context.rb
Overview
Value class for details about the request.
Instance Attribute Summary collapse
-
#base_url ⇒ Object
Returns the value of attribute base_url.
-
#body ⇒ Object
Returns the value of attribute body.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#operation ⇒ Object
Returns the value of attribute operation.
-
#params ⇒ Object
Returns the value of attribute params.
Instance Method Summary collapse
- #copy(**properties) ⇒ Object
- #full_path ⇒ Object
- #path ⇒ Object
- #query ⇒ Object
- #url ⇒ Object
- #verb ⇒ Object
Instance Attribute Details
#base_url ⇒ Object
Returns the value of attribute base_url
5 6 7 |
# File 'lib/reynard/request_context.rb', line 5 def base_url @base_url end |
#body ⇒ Object
Returns the value of attribute body
5 6 7 |
# File 'lib/reynard/request_context.rb', line 5 def body @body end |
#headers ⇒ Object
Returns the value of attribute headers
5 6 7 |
# File 'lib/reynard/request_context.rb', line 5 def headers @headers end |
#logger ⇒ Object
Returns the value of attribute logger
5 6 7 |
# File 'lib/reynard/request_context.rb', line 5 def logger @logger end |
#operation ⇒ Object
Returns the value of attribute operation
5 6 7 |
# File 'lib/reynard/request_context.rb', line 5 def operation @operation end |
#params ⇒ Object
Returns the value of attribute 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_path ⇒ Object
28 29 30 |
# File 'lib/reynard/request_context.rb', line 28 def full_path query_params? ? "#{path}?#{query}" : path end |
#path ⇒ Object
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 |
#query ⇒ Object
18 19 20 |
# File 'lib/reynard/request_context.rb', line 18 def query Rack::Utils.build_query(params['query']) if query_params? end |
#url ⇒ Object
32 33 34 35 36 |
# File 'lib/reynard/request_context.rb', line 32 def url return unless base_url "#{base_url}#{full_path}" end |
#verb ⇒ Object
14 15 16 |
# File 'lib/reynard/request_context.rb', line 14 def verb operation&.verb end |