class Chef::ChefFS::FileSystemCache
Public Class Methods
Source
# File lib/chef/chef_fs/file_system_cache.rb, line 26 def initialize @cache = {} Chef::Client.when_run_starts do FileSystemCache.instance.reset! end end
Public Instance Methods
Source
# File lib/chef/chef_fs/file_system_cache.rb, line 42 def children(path) @cache[path]["children"] end
Source
# File lib/chef/chef_fs/file_system_cache.rb, line 52 def delete!(path) parent = _get_parent(path) Chef::Log.trace("Deleting parent #{parent} and #{path} from FileSystemCache") if @cache.key?(path) @cache.delete(path) end if !parent.nil? && @cache.key?(parent) @cache.delete(parent) end end
Source
# File lib/chef/chef_fs/file_system_cache.rb, line 38 def exist?(path) @cache.key?(path) end
Source
# File lib/chef/chef_fs/file_system_cache.rb, line 63 def fetch(path) if @cache.key?(path) @cache[path] else false end end
Source
# File lib/chef/chef_fs/file_system_cache.rb, line 46 def set_children(path, val) @cache[path] ||= { "children" => [] } @cache[path]["children"] = val val end
Private Instance Methods
Source
# File lib/chef/chef_fs/file_system_cache.rb, line 73 def _get_parent(path) parts = ChefFS::PathUtils.split(path) return nil if parts.nil? || parts.length < 2 ChefFS::PathUtils.join(*parts[0..-2]) end