Clean up Platform#params.

State your normal case first, then deal with edge cases, not the other
way around.

Signed-off-by: Ryan Davis <zenspider@chef.io>
This commit is contained in:
Ryan Davis 2019-12-26 13:59:50 -08:00
parent aef285a1f6
commit 10cb92da48

View file

@ -27,7 +27,7 @@ module Inspec::Resources
end
def arch
@platform.arch
@platform.arch if @platform.respond_to?(:arch)
end
def families
@ -56,16 +56,16 @@ module Inspec::Resources
end
def params
# rubocop:disable Layout/AlignHash
h = {
name: name,
families: families,
release: release,
arch: arch,
}
# rubocop:enable Layout/AlignHash
# Avoid adding Arch for APIs (not applicable)
unless in_family?("api")
h[:arch] = arch
end
h.delete :arch if in_family?("api") # not applicable if api
h
end