summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2019-08-07 18:17:36 -0700
committerGitHub <noreply@github.com>2019-08-07 18:17:36 -0700
commitfaec827209e278f20cb070a85bb8593da1095716 (patch)
treeb0ab3e2c25327a2eeb57566dcc15a38e84baeca3
parent798384540841c404635448bf7367da70ae325f8e (diff)
parenta90264ea2573173debca60e3acad92f7865d7008 (diff)
downloadchef-faec827209e278f20cb070a85bb8593da1095716.tar.gz
Merge pull request #8800 from chef/lcg/consistent-not-passed
Consistently use NOT_PASSED over alternatives
-rw-r--r--lib/chef.rb3
-rw-r--r--lib/chef/decorator.rb9
-rw-r--r--lib/chef/exceptions.rb9
-rw-r--r--lib/chef/nil_argument.rb3
-rw-r--r--lib/chef/node.rb12
-rw-r--r--lib/chef/node/attribute.rb2
6 files changed, 15 insertions, 23 deletions
diff --git a/lib/chef.rb b/lib/chef.rb
index 945e9a6fe8..17b971ae5e 100644
--- a/lib/chef.rb
+++ b/lib/chef.rb
@@ -1,6 +1,6 @@
#
# Author:: Adam Jacob (<adam@chef.io>)
-# Copyright:: Copyright 2008-2017, Chef Software Inc.
+# Copyright:: Copyright 2008-2019, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,7 +18,6 @@
require_relative "chef/version"
-require_relative "chef/nil_argument"
require_relative "chef/mash"
require_relative "chef/exceptions"
require_relative "chef/log"
diff --git a/lib/chef/decorator.rb b/lib/chef/decorator.rb
index 17015bab94..d4d9a4ffc7 100644
--- a/lib/chef/decorator.rb
+++ b/lib/chef/decorator.rb
@@ -1,5 +1,5 @@
#--
-# Copyright:: Copyright 2016 Chef Software, Inc.
+# Copyright:: Copyright 2016-2019, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,14 +16,13 @@
#
require "delegate"
+require_relative "constants"
class Chef
class Decorator < SimpleDelegator
- NULL = ::Object.new
-
- def initialize(obj = NULL)
+ def initialize(obj = NOT_PASSED)
@__defined_methods__ = []
- super unless obj.equal?(NULL)
+ super unless obj.equal?(NOT_PASSED)
end
# if we wrap a nil then decorator.nil? should be true
diff --git a/lib/chef/exceptions.rb b/lib/chef/exceptions.rb
index 2d7ac374cb..7687e7d89c 100644
--- a/lib/chef/exceptions.rb
+++ b/lib/chef/exceptions.rb
@@ -2,7 +2,7 @@
# Author:: Adam Jacob (<adam@chef.io>)
# Author:: Seth Falcon (<seth@chef.io>)
# Author:: Kyle Goodwin (<kgoodwin@primerevenue.com>)
-# Copyright:: Copyright 2008-2018, Chef Software Inc.
+# Copyright:: Copyright 2008-2019, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -19,6 +19,7 @@
require "chef-config/exceptions"
require_relative "dist"
+require_relative "constants"
class Chef
# == Chef::Exceptions
@@ -264,14 +265,12 @@ class Chef
end
class MissingRole < RuntimeError
- NULL = Object.new
-
attr_reader :expansion
- def initialize(message_or_expansion = NULL)
+ def initialize(message_or_expansion = NOT_PASSED)
@expansion = nil
case message_or_expansion
- when NULL
+ when NOT_PASSED
super()
when String
super
diff --git a/lib/chef/nil_argument.rb b/lib/chef/nil_argument.rb
deleted file mode 100644
index c7cbc1b39e..0000000000
--- a/lib/chef/nil_argument.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-class Chef
- NIL_ARGUMENT = Object.new
-end
diff --git a/lib/chef/node.rb b/lib/chef/node.rb
index dfd2c685e1..ec20fbee86 100644
--- a/lib/chef/node.rb
+++ b/lib/chef/node.rb
@@ -20,8 +20,8 @@
require "forwardable" unless defined?(Forwardable)
require "securerandom" unless defined?(SecureRandom)
+require_relative "constants"
require_relative "config"
-require_relative "nil_argument"
require_relative "mixin/params_validate"
require_relative "mixin/from_file"
require_relative "mixin/deep_merge"
@@ -66,8 +66,6 @@ class Chef
include Chef::Mixin::ParamsValidate
- NULL_ARG = Object.new
-
# Create a new Chef::Node object.
def initialize(chef_server_rest: nil, logger: nil)
@chef_server_rest = chef_server_rest
@@ -152,8 +150,8 @@ class Chef
#
# @param arg [String] the new policy_name value
# @return [String] the current policy_name, or the one you just set
- def policy_name(arg = NULL_ARG)
- return @policy_name if arg.equal?(NULL_ARG)
+ def policy_name(arg = NOT_PASSED)
+ return @policy_name if arg.equal?(NOT_PASSED)
validate({ policy_name: arg }, { policy_name: { kind_of: [ String, NilClass ], regex: /^[\-:.[:alnum:]_]+$/ } })
@policy_name = arg
@@ -175,8 +173,8 @@ class Chef
#
# @param arg [String] the new policy_group value
# @return [String] the current policy_group, or the one you just set
- def policy_group(arg = NULL_ARG)
- return @policy_group if arg.equal?(NULL_ARG)
+ def policy_group(arg = NOT_PASSED)
+ return @policy_group if arg.equal?(NOT_PASSED)
validate({ policy_group: arg }, { policy_group: { kind_of: [ String, NilClass ], regex: /^[\-:.[:alnum:]_]+$/ } })
@policy_group = arg
diff --git a/lib/chef/node/attribute.rb b/lib/chef/node/attribute.rb
index bc4983384b..0beddf25f5 100644
--- a/lib/chef/node/attribute.rb
+++ b/lib/chef/node/attribute.rb
@@ -1,7 +1,7 @@
#--
# Author:: Adam Jacob (<adam@chef.io>)
# Author:: AJ Christensen (<aj@chef.io>)
-# Copyright:: Copyright 2008-2018, Chef Software Inc.
+# Copyright:: Copyright 2008-2019, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");