summaryrefslogtreecommitdiff
path: root/lib/chef/node.rb
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2019-08-07 17:07:40 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2019-08-07 17:07:40 -0700
commita90264ea2573173debca60e3acad92f7865d7008 (patch)
tree51b78f1566d719e961a2a82b2fedcca85a806888 /lib/chef/node.rb
parent5573e06c58d9ed40aa228d43fb943e3ef2999db5 (diff)
downloadchef-a90264ea2573173debca60e3acad92f7865d7008.tar.gz
Consistently use NOT_PASSED over alternatives
We have four different versions of this now, and this converts to just using the one convention in `lib/chef/constants.rb` Interestingly `Chef::NIL_ARGUMENT` is used nowhere in the codebase, that probably got refactored out in 12.5.1. Node objects still use `NIL` but that is a different kind of `Object.new` which really is semantically private to the implementation of attributes. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'lib/chef/node.rb')
-rw-r--r--lib/chef/node.rb12
1 files changed, 5 insertions, 7 deletions
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