Module: Scorpio::Request::Configurables
- Included in:
- Scorpio::Request
- Defined in:
- lib/scorpio/request.rb
Instance Attribute Summary collapse
- #base_url ⇒ Object
- #body ⇒ Object
-
#body_object ⇒ Object
Returns the value of attribute body_object.
- #faraday_adapter ⇒ Object
- #faraday_builder ⇒ Object
- #headers ⇒ Object
- #logger ⇒ Object
- #media_type ⇒ Object
- #path_params ⇒ Object
- #query_params ⇒ Object
- #scheme ⇒ Object
- #server ⇒ Object
- #server_variables ⇒ Object
- #user_agent ⇒ Object
Instance Attribute Details
#base_url ⇒ Object
44 45 46 47 |
# File 'lib/scorpio/request.rb', line 44 def base_url return @base_url if instance_variable_defined?(:@base_url) operation.base_url(scheme: scheme, server: server, server_variables: server_variables) end |
#body ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/scorpio/request.rb', line 50 def body return @body if instance_variable_defined?(:@body) if instance_variable_defined?(:@body_object) # TODO handle media types like `application/schema-instance+json` if media_type == 'application/json' JSON.pretty_generate(JSI::Typelike.as_json(body_object)) elsif media_type == "application/x-www-form-urlencoded" URI.encode_www_form(body_object) # NOTE: the supported media types above should correspond to Request::SUPPORTED_REQUEST_MEDIA_TYPES else if body_object.respond_to?(:to_str) body_object else raise(NotImplementedError, "Scorpio does not know how to generate the request body with media_type = #{media_type.respond_to?(:to_str) ? media_type : media_type.inspect} for operation: #{operation.human_id}. Scorpio supports media types: #{SUPPORTED_REQUEST_MEDIA_TYPES.join(', ')}. body_object was: #{body_object.pretty_inspect.chomp}") end end else nil end end |
#body_object ⇒ Object
Returns the value of attribute body_object.
73 74 75 |
# File 'lib/scorpio/request.rb', line 73 def body_object @body_object end |
#faraday_adapter ⇒ Object
100 101 102 103 |
# File 'lib/scorpio/request.rb', line 100 def faraday_adapter return @faraday_adapter if instance_variable_defined?(:@faraday_adapter) operation.faraday_adapter end |
#faraday_builder ⇒ Object
94 95 96 97 |
# File 'lib/scorpio/request.rb', line 94 def faraday_builder return @faraday_builder if instance_variable_defined?(:@faraday_builder) operation.faraday_builder end |
#headers ⇒ Object
76 77 78 79 |
# File 'lib/scorpio/request.rb', line 76 def headers return @headers if instance_variable_defined?(:@headers) operation.request_headers end |
#logger ⇒ Object
106 107 108 109 |
# File 'lib/scorpio/request.rb', line 106 def logger return @logger if instance_variable_defined?(:@logger) operation.logger end |
#media_type ⇒ Object
82 83 84 85 |
# File 'lib/scorpio/request.rb', line 82 def media_type return @media_type if instance_variable_defined?(:@media_type) content_type_header ? content_type_attrs.media_type : operation.request_media_type end |
#path_params ⇒ Object
14 15 16 17 |
# File 'lib/scorpio/request.rb', line 14 def path_params return @path_params if instance_variable_defined?(:@path_params) {}.freeze end |
#query_params ⇒ Object
20 21 22 23 |
# File 'lib/scorpio/request.rb', line 20 def query_params return @query_params if instance_variable_defined?(:@query_params) nil end |
#scheme ⇒ Object
26 27 28 29 |
# File 'lib/scorpio/request.rb', line 26 def scheme return @scheme if instance_variable_defined?(:@scheme) operation.scheme end |
#server ⇒ Object
32 33 34 35 |
# File 'lib/scorpio/request.rb', line 32 def server return @server if instance_variable_defined?(:@server) operation.server end |
#server_variables ⇒ Object
38 39 40 41 |
# File 'lib/scorpio/request.rb', line 38 def server_variables return @server_variables if instance_variable_defined?(:@server_variables) operation.server_variables end |
#user_agent ⇒ Object
88 89 90 91 |
# File 'lib/scorpio/request.rb', line 88 def user_agent return @user_agent if instance_variable_defined?(:@user_agent) operation.user_agent end |