Module: CobotClient::UrlHelper
Constant Summary collapse
- DEFAULT_SITE =
'https://www.cobot.me'
Class Method Summary collapse
-
.site ⇒ Object
set this to override the site for accessing the cobot api.
- .site=(site) ⇒ Object
Instance Method Summary collapse
-
#cobot_uri(subdomain = 'www', path = '/', params: {}) ⇒ Object
generates a uri to access the cobot api see the spec for usage examples.
- #cobot_url(subdomain = 'www', path = '/', params: {}) ⇒ Object
Class Method Details
.site ⇒ Object
set this to override the site for accessing the cobot api
8 9 10 |
# File 'lib/cobot_client/url_helper.rb', line 8 def self.site @site || DEFAULT_SITE end |
.site=(site) ⇒ Object
12 13 14 |
# File 'lib/cobot_client/url_helper.rb', line 12 def self.site=(site) @site = site end |
Instance Method Details
#cobot_uri(subdomain = 'www', path = '/', params: {}) ⇒ Object
generates a uri to access the cobot api see the spec for usage examples
18 19 20 21 22 23 24 25 |
# File 'lib/cobot_client/url_helper.rb', line 18 def cobot_uri(subdomain = 'www', path = '/', params: {}, **) uri = URI.parse(CobotClient::UrlHelper.site) uri.host = uri.host.split('.').tap { |parts| parts[0] = subdomain }.join('.') uri.path = path uri.query = URI.encode_www_form(params) unless params.empty? uri end |
#cobot_url(subdomain = 'www', path = '/', params: {}) ⇒ Object
27 28 29 |
# File 'lib/cobot_client/url_helper.rb', line 27 def cobot_url(subdomain = 'www', path = '/', params: {}, **) cobot_uri(subdomain, path, params: params, **).to_s end |