Class: HttpClientGenerator::Resource
- Inherits:
-
Object
- Object
- HttpClientGenerator::Resource
- Defined in:
- lib/http_client_generator/resource.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#base ⇒ Object
readonly
Returns the value of attribute base.
-
#content_type ⇒ Object
readonly
Returns the value of attribute content_type.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#req_plugs ⇒ Object
readonly
Returns the value of attribute req_plugs.
-
#resp_head_plugs ⇒ Object
readonly
Returns the value of attribute resp_head_plugs.
-
#resp_plugs ⇒ Object
readonly
Returns the value of attribute resp_plugs.
-
#stream ⇒ Object
readonly
Returns the value of attribute stream.
-
#timeout ⇒ Object
readonly
Returns the value of attribute timeout.
-
#verb ⇒ Object
readonly
Returns the value of attribute verb.
Instance Method Summary collapse
-
#initialize(verb:, content_type:, timeout:, name:, base:, req_plugs:, resp_head_plugs:, resp_plugs:, stream: false) ⇒ Resource
constructor
rubocop:disable Metrics/ParameterLists.
-
#perform_request(url_helper, url_options, body, rest_args, timeout_override) ⇒ Object
rubocop:enable Metrics/ParameterLists.
Constructor Details
#initialize(verb:, content_type:, timeout:, name:, base:, req_plugs:, resp_head_plugs:, resp_plugs:, stream: false) ⇒ Resource
rubocop:disable Metrics/ParameterLists
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/http_client_generator/resource.rb', line 10 def initialize(verb:, content_type:, timeout:, name:, base:, req_plugs:, resp_head_plugs:, resp_plugs:, stream: false) @verb = verb @base = base @content_type = content_type @timeout = timeout @name = name @stream = stream @req_plugs = select_plugs(req_plugs) @resp_head_plugs = select_plugs(resp_head_plugs) @resp_plugs = select_plugs(resp_plugs) validate_streaming_plugs! end |
Instance Attribute Details
#base ⇒ Object (readonly)
Returns the value of attribute base.
7 8 9 |
# File 'lib/http_client_generator/resource.rb', line 7 def base @base end |
#content_type ⇒ Object (readonly)
Returns the value of attribute content_type.
7 8 9 |
# File 'lib/http_client_generator/resource.rb', line 7 def content_type @content_type end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/http_client_generator/resource.rb', line 7 def name @name end |
#req_plugs ⇒ Object (readonly)
Returns the value of attribute req_plugs.
7 8 9 |
# File 'lib/http_client_generator/resource.rb', line 7 def req_plugs @req_plugs end |
#resp_head_plugs ⇒ Object (readonly)
Returns the value of attribute resp_head_plugs.
7 8 9 |
# File 'lib/http_client_generator/resource.rb', line 7 def resp_head_plugs @resp_head_plugs end |
#resp_plugs ⇒ Object (readonly)
Returns the value of attribute resp_plugs.
7 8 9 |
# File 'lib/http_client_generator/resource.rb', line 7 def resp_plugs @resp_plugs end |
#stream ⇒ Object (readonly)
Returns the value of attribute stream.
7 8 9 |
# File 'lib/http_client_generator/resource.rb', line 7 def stream @stream end |
#timeout ⇒ Object (readonly)
Returns the value of attribute timeout.
7 8 9 |
# File 'lib/http_client_generator/resource.rb', line 7 def timeout @timeout end |
#verb ⇒ Object (readonly)
Returns the value of attribute verb.
7 8 9 |
# File 'lib/http_client_generator/resource.rb', line 7 def verb @verb end |
Instance Method Details
#perform_request(url_helper, url_options, body, rest_args, timeout_override) ⇒ Object
rubocop:enable Metrics/ParameterLists
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/http_client_generator/resource.rb', line 25 def perform_request(url_helper, , body, rest_args, timeout_override) request = prepare_request(url_helper, , body, rest_args, timeout_override) response = perform_http_request(request) request.response_status = response.status.code request = process_response_head(request) return response.body if stream request.response_body = response.to_s process_response(request) rescue HTTP::Error => e request.raise_error(e) end |