Class: Vigia::HttpClient::Options

Inherits:
OpenStruct
  • Object
show all
Defined in:
lib/vigia/http_client/options.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.build(context, in_let_context) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/vigia/http_client/options.rb', line 5

def build(context, in_let_context)
  instance = new
  instance.context = context
  instance.options.each do |name, value|
    instance[name] = context.contextual_object(object: value, context: in_let_context)
  end
  instance.headers ||= {}
  instance.use_uri_template       if instance.uri_template
  instance.include_config_headers if Vigia.config.headers.any?
  instance
end

Instance Method Details

#include_config_headersObject



26
27
28
# File 'lib/vigia/http_client/options.rb', line 26

def include_config_headers
  self.headers.merge!(Vigia.config.headers)
end

#optionsObject



18
19
20
# File 'lib/vigia/http_client/options.rb', line 18

def options
  context.options[:http_client_options] || {}
end

#use_uri_templateObject



22
23
24
# File 'lib/vigia/http_client/options.rb', line 22

def use_uri_template
  self.url = Vigia::Url.new(uri_template).expand(parameters)
end