Method: Chef::ChefFS::FileSystem::BaseFSObject#child
- Defined in:
- lib/chef/chef_fs/file_system/base_fs_object.rb
#child(name) ⇒ Object
Get a child of this entry with the given name. This MUST always return a child, even if it is NonexistentFSObject. Overriders should take caution not to do expensive network requests to get the list of children to fulfill this request, unless absolutely necessary here; it is intended as a quick way to traverse a hierarchy.
For example, knife show /data_bags/x/y.json will call root.child(‘data_bags’).child(‘x’).child(‘y.json’), which can then directly perform a network request to retrieve the y.json data bag. No network request was necessary to retrieve
102 103 104 105 106 107 |
# File 'lib/chef/chef_fs/file_system/base_fs_object.rb', line 102 def child(name) if can_have_child?(name, true) || can_have_child?(name, false) result = make_child_entry(name) end result || NonexistentFSObject.new(name, self) end |