Class: ChefFS::FileSystem::DataBagDir
- Inherits:
-
RestListDir
- Object
- BaseFSObject
- BaseFSDir
- RestListDir
- ChefFS::FileSystem::DataBagDir
- Defined in:
- lib/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.
27 28 29 30 |
# File 'lib/chef_fs/file_system/data_bag_dir.rb', line 27 def initialize(name, parent, exists = nil) super(name, parent, nil, ChefFS::DataHandler::DataBagItemDataHandler.new) @exists = nil end |
Instance Method Details
#delete(recurse) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/chef_fs/file_system/data_bag_dir.rb', line 48 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_rest(api_path) rescue Timeout::Error => e raise ChefFS::FileSystem::OperationFailedError.new(:delete, self, e), "Timeout deleting: #{e}" rescue Net::HTTPServerException => e if e.response.code == "404" raise ChefFS::FileSystem::NotFoundError.new(self, e) else raise ChefFS::FileSystem::OperationFailedError.new(:delete, self, e), "HTTP error deleting: #{e}" end end end |
#dir? ⇒ Boolean
32 33 34 |
# File 'lib/chef_fs/file_system/data_bag_dir.rb', line 32 def dir? exists? end |
#exists? ⇒ Boolean
41 42 43 44 45 46 |
# File 'lib/chef_fs/file_system/data_bag_dir.rb', line 41 def exists? if @exists.nil? @exists = parent.children.any? { |child| child.name == name } end @exists end |
#read ⇒ Object
36 37 38 39 |
# File 'lib/chef_fs/file_system/data_bag_dir.rb', line 36 def read # This will only be called if dir? is false, which means exists? is false. raise ChefFS::FileSystem::NotFoundError.new(self) end |