Skip to content

Commit

Permalink
Check if an option has a default value before we try to look it up.
Browse files Browse the repository at this point in the history
This fixes fpm when used with clamp 1.3.0 or above.

Fixes #1543
  • Loading branch information
jordansissel committed Mar 26, 2023
1 parent ad6b18a commit b085edc
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/fpm/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,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
Expand Down

0 comments on commit b085edc

Please sign in to comment.