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
-
#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 |
# 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 iprocessor.intercept(:before_request, self) raw.run if self_executing && !response end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
12 13 14 |
# File 'lib/lhc/request.rb', line 12 def 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
32 33 34 |
# File 'lib/lhc/request.rb', line 32 def headers raw..fetch(:headers, nil) || raw.[:headers] = {} end |
#method ⇒ Object
28 29 30 |
# File 'lib/lhc/request.rb', line 28 def method (raw.[:method] || [:method] || :get).to_sym end |
#params ⇒ Object
36 37 38 |
# File 'lib/lhc/request.rb', line 36 def params raw..fetch(:params, nil) || raw.[:params] = {} end |
#url ⇒ Object
24 25 26 |
# File 'lib/lhc/request.rb', line 24 def url raw.base_url || [:url] end |