Class: Konfig::ProviderFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/konfig/provider_factory.rb

Class Method Summary collapse

Class Method Details

.create_provider(mode:, workdir:) ⇒ Object

Raises:

  • (ArgumentError)


3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/konfig/provider_factory.rb', line 3

def self.create_provider(mode:, workdir:)
  raise ArgumentError unless workdir
  raise ArgumentError unless [:yaml, :directory].include? mode

  if mode == :yaml
    return YamlProvider.new(workdir: workdir)
  elsif mode == :directory
    return DirectoryProvider.new(workdir: workdir)
  else
    raise ArgumentError
  end
end