diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2015-01-15 15:05:59 -0800 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2015-02-11 19:12:06 -0800 |
commit | 728717d1b5e489f82526b8390ab42846939392ee (patch) | |
tree | 770ffa29ce7464791352e2fd5864083b686f1226 /lib/chef/node.rb | |
parent | 3743da85e48f2fc57e48ed62c014c1070bb69f38 (diff) | |
download | chef-728717d1b5e489f82526b8390ab42846939392ee.tar.gz |
allow dep injecting chef_server_rest into objects
Diffstat (limited to 'lib/chef/node.rb')
-rw-r--r-- | lib/chef/node.rb | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/chef/node.rb b/lib/chef/node.rb index 6055f0e1e9..f9f6416f14 100644 --- a/lib/chef/node.rb +++ b/lib/chef/node.rb @@ -47,6 +47,8 @@ class Chef attr_accessor :recipe_list, :run_state, :override_runlist + attr_accessor :chef_server_rest + # RunContext will set itself as run_context via this setter when # initialized. This is needed so DSL::IncludeAttribute (in particular, # #include_recipe) can access the run_context to determine if an attributes @@ -62,7 +64,8 @@ class Chef include Chef::Mixin::ParamsValidate # Create a new Chef::Node object. - def initialize + def initialize(chef_server_rest: nil) + @chef_server_rest = chef_server_rest @name = nil @chef_environment = '_default' @@ -80,7 +83,7 @@ class Chef end def chef_server_rest - Chef::REST.new(Chef::Config[:chef_server_url]) + @chef_server_rest ||= Chef::REST.new(Chef::Config[:chef_server_url]) end # Set the name of this Node, or return the current name. |