Class: YuiRestClient::Http::VersionController
- Inherits:
-
Object
- Object
- YuiRestClient::Http::VersionController
- Defined in:
- lib/yui_rest_client/http/version_controller.rb
Instance Method Summary collapse
-
#api_version ⇒ Object
Gets server api version, so one could compare compatibility and detect if newer version was deployed.
-
#initialize(host:, port:) ⇒ VersionController
constructor
A new instance of VersionController.
Constructor Details
#initialize(host:, port:) ⇒ VersionController
Returns a new instance of VersionController.
6 7 8 9 10 11 |
# File 'lib/yui_rest_client/http/version_controller.rb', line 6 def initialize(host:, port:) @host = host @port = port @timeout = YuiRestClient.timeout @interval = YuiRestClient.interval end |
Instance Method Details
#api_version ⇒ Object
Gets server api version, so one could compare compatibility and detect if newer version was deployed
16 17 18 19 20 21 22 23 |
# File 'lib/yui_rest_client/http/version_controller.rb', line 16 def api_version Wait.until(timeout: @timeout, interval: @interval) do res = HttpClient.http_get(HttpClient.compose_uri(@host, @port, '/version')) raise Error::YuiRestClientError unless res.is_a?(Net::HTTPOK) JSON.parse(res.body)['api_version'] end end |