Skip to content

Commit

Permalink
reduce host#verbose_supports? calls to supports?
Browse files Browse the repository at this point in the history
now it only calls supports?() once (via unsupported_reason)
rather than twice before.

Besides that, it is the same
  • Loading branch information
kbrock committed Mar 29, 2024
1 parent 8795889 commit 181a03e
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions app/models/host.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1432,11 +1432,10 @@ def self.display_name(number = 1)
end

def verbose_supports?(feature, description = nil)
supports?(feature).tap do |value|
unless value
description ||= feature.to_s.humanize(:capitalize => false)
_log.warn("Cannot #{description} because <#{unsupported_reason(feature)}>")
end
if (reason = unsupported_reason(feature))
description ||= feature.to_s.humanize(:capitalize => false)
_log.warn("Cannot #{description} because <#{reason}>")
end
!reason
end
end

0 comments on commit 181a03e

Please # to comment.