Class: Chef::ChefFS::FileSystem::DataBagDir
- Inherits:
-
RestListDir
- Object
- BaseFSObject
- BaseFSDir
- RestListDir
- Chef::ChefFS::FileSystem::DataBagDir
- Defined in:
- lib/chef/chef_fs/file_system/data_bag_dir.rb
Instance Attribute Summary
Attributes inherited from RestListDir
Attributes inherited from BaseFSObject
Instance Method Summary collapse
- #delete(recurse) ⇒ Object
- #dir? ⇒ Boolean
- #exists? ⇒ Boolean
-
#initialize(name, parent, exists = nil) ⇒ DataBagDir
constructor
A new instance of DataBagDir.
- #read ⇒ Object
Methods inherited from RestListDir
#_make_child_entry, #can_have_child?, #child, #children, #create_child, #environment, #org, #rest
Methods inherited from BaseFSDir
Methods inherited from BaseFSObject
#can_have_child?, #chef_object, #child, #children, #compare_to, #create_child, #path_for_printing, #root, #write
Constructor Details
#initialize(name, parent, exists = nil) ⇒ DataBagDir
Returns a new instance of DataBagDir.
28 29 30 31 |
# File 'lib/chef/chef_fs/file_system/data_bag_dir.rb', line 28 def initialize(name, parent, exists = nil) super(name, parent, nil, Chef::ChefFS::DataHandler::DataBagItemDataHandler.new) @exists = nil end |
Instance Method Details
#delete(recurse) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/chef/chef_fs/file_system/data_bag_dir.rb', line 49 def delete(recurse) if !recurse raise NotFoundError.new(self) if !exists? raise MustDeleteRecursivelyError.new(self), "#{path_for_printing} must be deleted recursively" end begin rest.delete(api_path) rescue Timeout::Error => e raise Chef::ChefFS::FileSystem::OperationFailedError.new(:delete, self, e), "Timeout deleting: #{e}" rescue Net::HTTPServerException => e if e.response.code == "404" raise Chef::ChefFS::FileSystem::NotFoundError.new(self, e) else raise Chef::ChefFS::FileSystem::OperationFailedError.new(:delete, self, e), "HTTP error deleting: #{e}" end end end |
#dir? ⇒ Boolean
33 34 35 |
# File 'lib/chef/chef_fs/file_system/data_bag_dir.rb', line 33 def dir? exists? end |
#exists? ⇒ Boolean
42 43 44 45 46 47 |
# File 'lib/chef/chef_fs/file_system/data_bag_dir.rb', line 42 def exists? if @exists.nil? @exists = parent.children.any? { |child| child.name == name } end @exists end |
#read ⇒ Object
37 38 39 40 |
# File 'lib/chef/chef_fs/file_system/data_bag_dir.rb', line 37 def read # This will only be called if dir? is false, which means exists? is false. raise Chef::ChefFS::FileSystem::NotFoundError.new(self) end |