Class: PactBroker::Config::Save

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/pact_broker/config/save.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Logging

included, #log_error, #log_with_tag, #measure_info

Constructor Details

#initialize(configuration, setting_names) ⇒ Save

Returns a new instance of Save.



16
17
18
19
20
# File 'lib/pact_broker/config/save.rb', line 16

def initialize configuration, setting_names
  @configuration = configuration
  @setting_names = setting_names
  @repository = Config::Repository.new
end

Class Method Details

.call(configuration, setting_names) ⇒ Object



12
13
14
# File 'lib/pact_broker/config/save.rb', line 12

def self.call configuration, setting_names
  new(configuration, setting_names).call
end

Instance Method Details

#callObject



22
23
24
25
26
27
28
29
30
31
# File 'lib/pact_broker/config/save.rb', line 22

def call
  setting_names.each do | setting_name |
    setting_value = get_value(setting_name)
    if repository.class_supported?(setting_value)
      create_or_update_setting(setting_name, setting_value)
    else
      logger.warn "Could not save configuration setting \"#{setting_name}\" to database as the class #{setting_value.class} is not supported."
    end
  end
end