Class: Safettp::HTTPOptions
- Inherits:
-
Object
- Object
- Safettp::HTTPOptions
- Defined in:
- lib/safettp/http_options.rb
Constant Summary collapse
- AUTHENTICATORS =
{ none: Safettp::NoneAuthenticator, basic: Safettp::BasicAuthenticator }.freeze
- DEFAULT_HEADERS =
{ Accept: 'application/json', 'Content-Type': 'application/json' }.freeze
Instance Attribute Summary collapse
-
#options_hash ⇒ Object
readonly
Returns the value of attribute options_hash.
Instance Method Summary collapse
- #authorization ⇒ Object
- #body ⇒ Object
- #headers ⇒ Object
-
#initialize(options_hash = {}) ⇒ HTTPOptions
constructor
A new instance of HTTPOptions.
- #parser ⇒ Object
- #query ⇒ Object
Constructor Details
#initialize(options_hash = {}) ⇒ HTTPOptions
Returns a new instance of HTTPOptions.
14 15 16 |
# File 'lib/safettp/http_options.rb', line 14 def initialize( = {}) @options_hash = end |
Instance Attribute Details
#options_hash ⇒ Object (readonly)
Returns the value of attribute options_hash.
12 13 14 |
# File 'lib/safettp/http_options.rb', line 12 def @options_hash end |
Instance Method Details
#authorization ⇒ Object
34 35 36 37 38 |
# File 'lib/safettp/http_options.rb', line 34 def = .fetch(:authorization, { type: :none }) AUTHENTICATORS.fetch([:type], Safettp::NoneAuthenticator) .new() end |
#body ⇒ Object
30 31 32 |
# File 'lib/safettp/http_options.rb', line 30 def body .fetch(:body, "") end |
#headers ⇒ Object
18 19 20 |
# File 'lib/safettp/http_options.rb', line 18 def headers .fetch(:headers, DEFAULT_HEADERS) end |
#parser ⇒ Object
22 23 24 |
# File 'lib/safettp/http_options.rb', line 22 def parser .fetch(:parser, Safettp::Parsers::JSON) end |
#query ⇒ Object
26 27 28 |
# File 'lib/safettp/http_options.rb', line 26 def query URI.encode_www_form(.fetch(:query, {})) end |