Class: LHC::Request
- Inherits:
-
Object
- Object
- LHC::Request
- Defined in:
- lib/lhc/request.rb
Overview
The request is doing an http-request using typhoeus. It provides functionalities to access and alter request data and it communicates with interceptors.
Constant Summary collapse
- TYPHOEUS_OPTIONS =
[:params, :method, :body, :headers, :follow_location]
Instance Attribute Summary collapse
-
#format ⇒ Object
Returns the value of attribute format.
-
#options ⇒ Object
Returns the value of attribute options.
-
#raw ⇒ Object
Returns the value of attribute raw.
-
#response ⇒ Object
Returns the value of attribute response.
Instance Method Summary collapse
- #headers ⇒ Object
-
#initialize(options, self_executing = true) ⇒ Request
constructor
A new instance of Request.
- #method ⇒ Object
- #params ⇒ Object
- #url ⇒ Object
Constructor Details
#initialize(options, self_executing = true) ⇒ Request
Returns a new instance of Request.
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/lhc/request.rb', line 14 def initialize(, self_executing = true) self. = .deep_dup || {} use_configured_endpoint! generate_url_from_template! self.iprocessor = LHC::InterceptorProcessor.new(self) self.raw = create_request self.format = .delete('format') || JsonFormat.new iprocessor.intercept(:before_request, self) raw.run if self_executing && !response end |
Instance Attribute Details
#format ⇒ Object
Returns the value of attribute format.
12 13 14 |
# File 'lib/lhc/request.rb', line 12 def format @format end |
#options ⇒ Object
Returns the value of attribute options.
12 13 14 |
# File 'lib/lhc/request.rb', line 12 def @options end |
#raw ⇒ Object
Returns the value of attribute raw.
12 13 14 |
# File 'lib/lhc/request.rb', line 12 def raw @raw end |
#response ⇒ Object
Returns the value of attribute response.
12 13 14 |
# File 'lib/lhc/request.rb', line 12 def response @response end |
Instance Method Details
#headers ⇒ Object
33 34 35 |
# File 'lib/lhc/request.rb', line 33 def headers raw..fetch(:headers, nil) || raw.[:headers] = {} end |
#method ⇒ Object
29 30 31 |
# File 'lib/lhc/request.rb', line 29 def method (raw.[:method] || [:method] || :get).to_sym end |
#params ⇒ Object
37 38 39 |
# File 'lib/lhc/request.rb', line 37 def params raw..fetch(:params, nil) || raw.[:params] = {} end |
#url ⇒ Object
25 26 27 |
# File 'lib/lhc/request.rb', line 25 def url raw.base_url || [:url] end |