From 80a47264aed62c65f46d8f873c843cd013cb0dfd Mon Sep 17 00:00:00 2001 From: Evan Phoenix Date: Fri, 19 Feb 2016 17:05:59 -0800 Subject: [PATCH] Clamp dynamic defaults properly --- lib/puma/configuration.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/puma/configuration.rb b/lib/puma/configuration.rb index c65575d9..d76f57fd 100644 --- a/lib/puma/configuration.rb +++ b/lib/puma/configuration.rb @@ -16,7 +16,7 @@ module Puma def initialize(default={}) @cur = {} @set = [@cur] - @defaults = default + @defaults = default.dup end def initialize_copy(other) @@ -105,6 +105,14 @@ module Puma indent = " #{indent}" end end + + def force_defaults + @defaults.each do |k,v| + if v.respond_to? :call + @defaults[k] = v.call + end + end + end end class Configuration @@ -198,6 +206,7 @@ module Puma # is loaded to flesh out any defaults def clamp @options.shift + @options.force_defaults end # Injects the Configuration object into the env