Class: Duffel
- Inherits:
-
Object
- Object
- Duffel
- Defined in:
- lib/duffel.rb
Constant Summary collapse
- VERSION =
"0.0.1"
Class Method Summary collapse
Class Method Details
.method_missing(method, *args, &block) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/duffel.rb', line 4 def self.method_missing(method, *args, &block) fetch_default = lambda do |key| raise KeyError.new("key not found: #{key}") end define_singleton_method(method) do |=(args.first || {})| return_value = .fetch(:fallback, fetch_default) fallback = return_value.is_a?(Proc) ? return_value : lambda { |key| return_value } env_name = method.to_s.upcase ENV.fetch(env_name, &fallback) end self.send(method) end |