Module: Vayacondios::Configliere

Defined in:
lib/vayacondios/client/configliere.rb

Instance Method Summary collapse

Instance Method Details

#load_from_vayacondios(organization, id, options = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/vayacondios/client/configliere.rb', line 4

def load_from_vayacondios(organization, id, options = {})
  options.symbolize_keys!.deep_merge!(organization: organization)

  client = ::Vayacondios::HttpClient.receive(options.deep_compact!)
  id     = [id, options[:env]].compact.join('.')
  
  begin
    new_data = client.fetch(:config, id)
  rescue ::Vayacondios::HttpClient::Error
    warn "Unable to load vayacondios config '#{id}' for #{organization} at: #{client.host}:#{client.port}"
    new_data = {}
  end
  deep_merge! new_data
  self
end

#save_to_vayacondios(organization, id, options = {}) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/vayacondios/client/configliere.rb', line 20

def save_to_vayacondios(organization, id, options = {})
  options.symbolize_keys!.deep_merge!(organization: organization)

  client = ::Vayacondios::HttpClient.receive(options.deep_compact!)
  id = [id, options[:env]].compact.join('.')
  
  begin
    client.insert(self.to_hash, :config, id)
  rescue ::Vayacondios::HttpClient::Error
    warn "Unable to save vayacondios config '#{id}' for #{organization} at: #{client.host}:#{client.port}"
  end
  self
end