From 956a218a7b35de08ea35da3b702ffdc716656b68 Mon Sep 17 00:00:00 2001 From: Jordan Sissel Date: Mon, 15 Oct 2018 21:05:47 -0700 Subject: [PATCH] Check if an option has a default value before we try to look it up. This fixes fpm when used with clamp 1.3.0 or above. Fixes #1543 --- lib/fpm/command.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/fpm/command.rb b/lib/fpm/command.rb index a204001e16..a99ddb6270 100644 --- a/lib/fpm/command.rb +++ b/lib/fpm/command.rb @@ -394,7 +394,12 @@ def execute set = proc do |object, attribute| # if the package's attribute is currently nil *or* the flag setting for this # attribute is non-default, use the value. - if object.send(attribute).nil? || send(attribute) != send("default_#{attribute}") + + # Not all options have a default value, so we assume `nil` if there's no default. (#1543) + # In clamp >= 1.3.0, options without `:default => ..` will not have any # `default_xyz` + # methods generated, so we need to check for the presence of this method first. + default = respond_to?("default_#{attribute}") ? send("default_#{attribute}") : nil + if object.send(attribute).nil? || send(attribute) != default logger.info("Setting from flags: #{attribute}=#{send(attribute)}") object.send("#{attribute}=", send(attribute)) end