Sha256: 02da301819551b85bb7a309f0a65e39475af035958d994f9bec2be1bab85481c

Contents?: true

Size: 1.25 KB

Versions: 67

Compression:

Stored size: 1.25 KB

Contents

require 'pact_broker/configuration'
require 'pact_broker/logging'
require 'pact_broker/config/setting'
require 'pact_broker/config/repository'

module PactBroker
  module Config
    class Save

      include PactBroker::Logging

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

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

      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

      private

      attr_reader :configuration, :setting_names, :repository

      def create_or_update_setting setting_name, setting_value
        repository.create_or_update_setting(setting_name, setting_value)
      end

      def get_value setting_name
        configuration.send(setting_name)
      end
    end
  end
end

Version data entries

67 entries across 67 versions & 1 rubygems

Version Path
pact_broker-2.79.1 lib/pact_broker/config/save.rb
pact_broker-2.79.0 lib/pact_broker/config/save.rb
pact_broker-2.78.1 lib/pact_broker/config/save.rb
pact_broker-2.78.0 lib/pact_broker/config/save.rb
pact_broker-2.77.0 lib/pact_broker/config/save.rb
pact_broker-2.76.2 lib/pact_broker/config/save.rb
pact_broker-2.76.1 lib/pact_broker/config/save.rb
pact_broker-2.76.0 lib/pact_broker/config/save.rb
pact_broker-2.75.0 lib/pact_broker/config/save.rb
pact_broker-2.74.1 lib/pact_broker/config/save.rb
pact_broker-2.74.0 lib/pact_broker/config/save.rb
pact_broker-2.73.0 lib/pact_broker/config/save.rb
pact_broker-2.72.0 lib/pact_broker/config/save.rb
pact_broker-2.71.0 lib/pact_broker/config/save.rb
pact_broker-2.70.0 lib/pact_broker/config/save.rb
pact_broker-2.69.0 lib/pact_broker/config/save.rb
pact_broker-2.68.1 lib/pact_broker/config/save.rb
pact_broker-2.68.0 lib/pact_broker/config/save.rb
pact_broker-2.67.0 lib/pact_broker/config/save.rb
pact_broker-2.66.0 lib/pact_broker/config/save.rb