# File lib/chef/chef_fs/file_system/rest_list_dir.rb, line 78 def _make_child_entry(name, exists = nil) RestListEntry.new(name, self, exists) end
# File lib/chef/chef_fs/file_system/rest_list_dir.rb, line 40 def can_have_child?(name, is_dir) name =~ /\.json$/ && !is_dir end
# File lib/chef/chef_fs/file_system/rest_list_dir.rb, line 34 def child(name) result = @children.select { |child| child.name == name }.first if @children result ||= can_have_child?(name, false) ? _make_child_entry(name) : NonexistentFSObject.new(name, self) end
# File lib/chef/chef_fs/file_system/rest_list_dir.rb, line 44 def children begin @children ||= rest.get_rest(api_path).keys.map do |key| _make_child_entry("#{key}.json", true) end rescue Net::HTTPServerException if $!.response.code == "404" raise Chef::ChefFS::FileSystem::NotFoundError.new($!), "#{path_for_printing} not found" else raise end end end
NOTE if you change this significantly, you will likely need to change DataBagDir.create_child as well.
# File lib/chef/chef_fs/file_system/rest_list_dir.rb, line 60 def create_child(name, file_contents) json = Chef::JSONCompat.from_json(file_contents).to_hash base_name = name[0,name.length-5] if json.include?('name') && json['name'] != base_name raise "Name in #{path_for_printing}/#{name} must be '#{base_name}' (is '#{json['name']}')" end rest.post_rest(api_path, json) _make_child_entry(name, true) end
Generated with the Darkfish Rdoc Generator 2.