Sha256: 88c956313710e6ada2e300a097ad1b2a9134e29ad1b829bc57e674fa6ce9d0fe

Contents?: true

Size: 1.11 KB

Versions: 67

Compression:

Stored size: 1.11 KB

Contents

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

module PactBroker
  module Config
    class Load

      include PactBroker::Logging

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

      def initialize configuration
        @configuration = configuration
      end

      def call
        Setting.each do | setting |
          set_value_on_configuration setting
        end
      end

      private

      attr_reader :configuration

      def configuration_attribute_exists? setting
        configuration.respond_to?("#{setting.name}=")
      end

      def set_value_on_configuration setting
        if configuration_attribute_exists? setting
          logger.debug("Loading #{setting.name} configuration from database.")
          configuration.send("#{setting.name}=", setting.value_object)
        else
          logger.warn("Could not load configuration setting \"#{setting.name}\" as there is no matching attribute on the Configuration class")
        end
      end
    end
  end
end

Version data entries

67 entries across 67 versions & 1 rubygems

Version Path
pact_broker-2.65.0 lib/pact_broker/config/load.rb
pact_broker-2.64.0 lib/pact_broker/config/load.rb
pact_broker-2.63.0 lib/pact_broker/config/load.rb
pact_broker-2.62.0 lib/pact_broker/config/load.rb
pact_broker-2.61.0 lib/pact_broker/config/load.rb
pact_broker-2.60.1 lib/pact_broker/config/load.rb
pact_broker-2.60.0 lib/pact_broker/config/load.rb
pact_broker-2.59.2 lib/pact_broker/config/load.rb
pact_broker-2.59.1 lib/pact_broker/config/load.rb
pact_broker-2.59.0 lib/pact_broker/config/load.rb
pact_broker-2.58.3 lib/pact_broker/config/load.rb
pact_broker-2.58.2 lib/pact_broker/config/load.rb
pact_broker-2.58.0 lib/pact_broker/config/load.rb
pact_broker-2.57.0 lib/pact_broker/config/load.rb
pact_broker-2.56.1 lib/pact_broker/config/load.rb
pact_broker-2.56.0 lib/pact_broker/config/load.rb
pact_broker-2.55.0 lib/pact_broker/config/load.rb
pact_broker-2.54.0 lib/pact_broker/config/load.rb
pact_broker-2.53.0 lib/pact_broker/config/load.rb
pact_broker-2.52.2 lib/pact_broker/config/load.rb