class DiceBag::Configuration::PrefixedWithFallback
This class acts like Configuration
but with a prefix applied to the environment variables used to provide values. This is useful for providing per-environment overrides to value in Rails projects. If the prefixed environment variable is not found, the class delegates to the provided fallback Configuration
class, without the prefix.
Public Class Methods
new(prefix, fallback)
click to toggle source
# File lib/dice_bag/configuration.rb, line 51 def initialize(prefix, fallback) @prefix = prefix.to_s.upcase @fallback = fallback end
Public Instance Methods
method_missing(name)
click to toggle source
# File lib/dice_bag/configuration.rb, line 56 def method_missing(name) ENV["#{@prefix}_#{name.to_s.upcase}"] || @fallback.send(name) end