Class: Philiprehberger::FeatureFlag::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/philiprehberger/feature_flag/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



8
9
10
# File 'lib/philiprehberger/feature_flag/configuration.rb', line 8

def initialize
  @backend = Backends::MemoryBackend.new
end

Instance Attribute Details

#backendObject

Returns the value of attribute backend.



6
7
8
# File 'lib/philiprehberger/feature_flag/configuration.rb', line 6

def backend
  @backend
end

Instance Method Details

#use(type, **options) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/philiprehberger/feature_flag/configuration.rb', line 12

def use(type, **options)
  @backend = case type
             when :memory then Backends::MemoryBackend.new
             when :env    then Backends::EnvBackend.new
             when :yaml   then Backends::YamlBackend.new(options[:path])
             else raise ArgumentError, "unknown backend: #{type}"
             end
end