Sha256: 37d7a274dd45bdaef7d186100af64bd4a0405afb9e58b72f0d3224d863447f65
Contents?: true
Size: 698 Bytes
Versions: 1
Compression:
Stored size: 698 Bytes
Contents
class Duffel VERSION = "0.0.2" class << self def method_missing(method, *args, &block) define_singleton_method(method) do |options={}| options ||= {} return_value = options.fetch(:fallback, fetch_default) fallback = format_return_value(return_value) env_name = method.to_s.upcase ENV.fetch(env_name, &fallback) end self.send(method, args.first) end protected def format_return_value(value) if value.is_a?(Proc) value else lambda { |_key| value } end end def fetch_default lambda do |key| raise KeyError.new("key not found: #{key}") end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
duffel-0.0.2 | lib/duffel.rb |