Module: Scorpio::Request::Configurables
- Included in:
- Scorpio::Request
- Defined in:
- lib/scorpio/request.rb
Instance Attribute Summary collapse
- #accept ⇒ Object
- #authorization ⇒ Object
- #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 Method Summary collapse
-
#url=(url) ⇒ Object
overriding url will cause all of path_params, query_params, querystring, scheme, server, server_variables, and base_url to be ignored.
Instance Attribute Details
#accept ⇒ Object
114 115 116 117 |
# File 'lib/scorpio/request.rb', line 114 def accept return @accept if instance_variable_defined?(:@accept) operation.accept end |
#authorization ⇒ Object
120 121 122 123 |
# File 'lib/scorpio/request.rb', line 120 def return @authorization if instance_variable_defined?(:@authorization) operation. end |
#base_url ⇒ Object
60 61 62 63 |
# File 'lib/scorpio/request.rb', line 60 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
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/scorpio/request.rb', line 71 def body return @body if instance_variable_defined?(:@body) if instance_variable_defined?(:@body_object) if content_type && content_type.json? JSON.pretty_generate(JSI::Util.as_json(body_object)) elsif content_type && content_type.form_urlencoded? URI.encode_www_form(body_object) # NOTE: the supported media types above should correspond to Request::SUPPORTED_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 content_type = #{content_type.respond_to?(:to_str) ? content_type : content_type.inspect} for operation: #{operation.human_id}. Scorpio supports media types: #{SUPPORTED_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.
93 94 95 |
# File 'lib/scorpio/request.rb', line 93 def body_object @body_object end |
#faraday_adapter ⇒ Object
132 133 134 135 |
# File 'lib/scorpio/request.rb', line 132 def faraday_adapter return @faraday_adapter if instance_variable_defined?(:@faraday_adapter) operation.faraday_adapter end |
#faraday_builder ⇒ Object
126 127 128 129 |
# File 'lib/scorpio/request.rb', line 126 def faraday_builder return @faraday_builder if instance_variable_defined?(:@faraday_builder) operation.faraday_builder end |
#headers ⇒ Object
96 97 98 99 |
# File 'lib/scorpio/request.rb', line 96 def headers return @headers if instance_variable_defined?(:@headers) operation.request_headers end |
#logger ⇒ Object
138 139 140 141 |
# File 'lib/scorpio/request.rb', line 138 def logger return @logger if instance_variable_defined?(:@logger) operation.logger end |
#media_type ⇒ Object
102 103 104 105 |
# File 'lib/scorpio/request.rb', line 102 def media_type return @media_type if instance_variable_defined?(:@media_type) content_type_header ? content_type_header.media_type : operation.request_media_type end |
#path_params ⇒ Object
30 31 32 33 |
# File 'lib/scorpio/request.rb', line 30 def path_params return @path_params if instance_variable_defined?(:@path_params) {}.freeze end |
#query_params ⇒ Object
36 37 38 39 |
# File 'lib/scorpio/request.rb', line 36 def query_params return @query_params if instance_variable_defined?(:@query_params) nil end |
#scheme ⇒ Object
42 43 44 45 |
# File 'lib/scorpio/request.rb', line 42 def scheme return @scheme if instance_variable_defined?(:@scheme) operation.scheme end |
#server ⇒ Object
48 49 50 51 |
# File 'lib/scorpio/request.rb', line 48 def server return @server if instance_variable_defined?(:@server) operation.server end |
#server_variables ⇒ Object
54 55 56 57 |
# File 'lib/scorpio/request.rb', line 54 def server_variables return @server_variables if instance_variable_defined?(:@server_variables) operation.server_variables end |
#user_agent ⇒ Object
108 109 110 111 |
# File 'lib/scorpio/request.rb', line 108 def user_agent return @user_agent if instance_variable_defined?(:@user_agent) operation.user_agent end |
Instance Method Details
#url=(url) ⇒ Object
overriding url will cause all of path_params, query_params, querystring, scheme, server, server_variables, and base_url to be ignored
66 67 68 |
# File 'lib/scorpio/request.rb', line 66 def url=(url) @url = JSI::Util.uri(url) end |