Using ObjectSpace to locate the Chef::Node instance in a library

What are your thoughts about doing something like this in a Chef library to get access to the Chef::Node instance early in the compile phase?

node = ObjectSpace.each_object(Chef::Node).to_a.first

if you’re using ObjectSpace for anything other than debugging memory leaks, it’s probably a bad idea. Chef provides you with Chef.node for this purpose: https://github.com/chef/chef/blob/master/lib/chef/chef_class.rb

Ah… that is SO much better. Thank you