Class: Protein::HTTPAdapter
- Inherits:
-
Object
- Object
- Protein::HTTPAdapter
- Defined in:
- lib/protein/http_adapter.rb
Defined Under Namespace
Classes: Middleware
Constant Summary collapse
- HTTPS_SCHEME =
"https".freeze
Class Method Summary collapse
- .call(request_payload) ⇒ Object
- .from_hash(hash) ⇒ Object
- .path(path = nil) ⇒ Object
- .secret(secret = nil) ⇒ Object
- .url(url = nil) ⇒ Object
Class Method Details
.call(request_payload) ⇒ Object
66 67 68 |
# File 'lib/protein/http_adapter.rb', line 66 def call(request_payload) make_http_request(request_payload, build_headers()) end |
.from_hash(hash) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/protein/http_adapter.rb', line 33 def from_hash(hash) if (new_url = hash[:url]) url(new_url) end if (new_path = hash[:path]) path(new_path) end if (new_secret = hash[:secret]) secret(new_secret) end end |
.path(path = nil) ⇒ Object
56 57 58 59 |
# File 'lib/protein/http_adapter.rb', line 56 def path(path = nil) @path = path if path @path || raise(DefinitionError, "path is not defined") end |
.secret(secret = nil) ⇒ Object
61 62 63 64 |
# File 'lib/protein/http_adapter.rb', line 61 def secret(secret = nil) @secret = secret if secret @secret || raise(DefinitionError, "secret is not defined") end |
.url(url = nil) ⇒ Object
47 48 49 50 51 52 53 54 |
# File 'lib/protein/http_adapter.rb', line 47 def url(url = nil) if url @url = url @path = URI(url).path end @url || raise(DefinitionError, "url is not defined") end |