diff options
Diffstat (limited to 'lib/chef/version_class.rb')
-rw-r--r-- | lib/chef/version_class.rb | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/chef/version_class.rb b/lib/chef/version_class.rb index 35a9f3282f..f018833717 100644 --- a/lib/chef/version_class.rb +++ b/lib/chef/version_class.rb @@ -34,8 +34,13 @@ class Chef def <=>(v) [:major, :minor, :patch].each do |method| - ans = (self.send(method) <=> v.send(method)) - return ans if ans != 0 + version = self.send(method) + begin + ans = (version <=> v.send(method)) + rescue NoMethodError # if the other thing isn't a version object, return nil + return nil + end + return ans unless ans == 0 end 0 end |