Class: EhbrsRubyUtils::WebUtils::Instance

Inherits:
Avm::Instances::Base
  • Object
show all
Defined in:
lib/ehbrs_ruby_utils/web_utils/instance.rb

Instance Method Summary collapse

Instance Method Details

#http_client_uncachedObject



24
25
26
27
28
29
# File 'lib/ehbrs_ruby_utils/web_utils/instance.rb', line 24

def http_client_uncached
  client = HTTPClient.new
  client.force_basic_auth = true
  client.set_basic_auth(root_url, read_entry(:admin_username), read_entry(:admin_password))
  client
end

#http_request(resource_url_suffix, options = {}) ⇒ Object



18
19
20
21
22
# File 'lib/ehbrs_ruby_utils/web_utils/instance.rb', line 18

def http_request(resource_url_suffix, options = {})
  method = options.delete(:method) || 'get'
  url = resource_url(resource_url_suffix)
  http_client.request(method, url, options)
end

#resource_url(resource_url_suffix) ⇒ Object



14
15
16
# File 'lib/ehbrs_ruby_utils/web_utils/instance.rb', line 14

def resource_url(resource_url_suffix)
  root_url + '/' + resource_url_suffix.gsub(%r{\A/+}, '')
end

#root_urlObject



10
11
12
# File 'lib/ehbrs_ruby_utils/web_utils/instance.rb', line 10

def root_url
  read_entry(:url)
end