Class: ResponseMate::Request
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- ResponseMate::Request
- Defined in:
- lib/response_mate/request.rb
Overview
Responsible for keeping all logic related to a request defined in the requests manifest
Instance Method Summary collapse
-
#normalize! ⇒ Object
Make sure all defined requests in the manifest have complete information for Connection#fetch.
-
#to_cli_format ⇒ String
Output string suitable for a terminal.
-
#to_hash ⇒ Hash
The Hash representation of the request.
Instance Method Details
#normalize! ⇒ Object
Make sure all defined requests in the manifest have complete information for Connection#fetch
8 9 10 11 12 13 14 15 16 |
# File 'lib/response_mate/request.rb', line 8 def normalize! unless ResponseMate::HTTP_METHODS.include? request[:verb] request[:verb] = 'GET' end request[:url] = URI.encode(adjust_scheme(request[:url], request[:scheme])) self end |
#to_cli_format ⇒ String
Returns Output string suitable for a terminal.
19 20 21 22 23 |
# File 'lib/response_mate/request.rb', line 19 def to_cli_format out = "[#{key}] #{request[:verb]}".cyan_on_black.bold << " #{request[:url]}" out << "\tparams #{request[:params]}" if request[:params].present? out end |
#to_hash ⇒ Hash
Returns The Hash representation of the request.
26 27 28 |
# File 'lib/response_mate/request.rb', line 26 def to_hash marshal_dump[:request] end |