Sha256: bb33e6476e4e390275577421276f6040c29888f84cf633cc7ee4d5abb2068b26

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

module PansophyAuthenticator
  module Configuration
    class Configurator
      attr_accessor :local, :bucket_name, :file_path, :configuration_path, :application
      attr_writer :cache_store

      def configuration
        build_configuration
      end

      def cache_store
        @cache_store ||= CacheStores::Memory.new
      end

      private

      def build_configuration
        attrs = {
          bucket_name: config_values.bucket_name,
          file_path:   config_values.file_path,
          application: config_values.application,
          cache_store: cache_store
        }
        if config_values.local
          Local.new(attrs)
        else
          Remote.new(attrs)
        end
      end

      def config_values
        @config_values ||= from_env_or_base
      end

      def from_env_or_base
        FromEnv.new(base_config)
      end

      def base_config
        return self if @configuration_path.nil?
        from_file_or_base
      end

      def from_file_or_base
        FromFile.new(self)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pansophy_authenticator-0.5.0 lib/pansophy_authenticator/configuration/configurator.rb