Files

Class/Module Index [+]

Quicksearch

Chef::ChefFS::FileSystem::DataBagDir

Public Class Methods

new(name, parent, exists = nil) click to toggle source
# File lib/chef/chef_fs/file_system/data_bag_dir.rb, line 28
def initialize(name, parent, exists = nil)
  super(name, parent)
  @exists = nil
end

Public Instance Methods

_make_child_entry(name, exists = nil) click to toggle source
# File lib/chef/chef_fs/file_system/data_bag_dir.rb, line 59
def _make_child_entry(name, exists = nil)
  DataBagItem.new(name, self, exists)
end
create_child(name, file_contents) click to toggle source
# File lib/chef/chef_fs/file_system/data_bag_dir.rb, line 49
def create_child(name, file_contents)
  json = Chef::JSONCompat.from_json(file_contents).to_hash
  id = name[0,name.length-5]
  if json.include?('id') && json['id'] != id
    raise "ID in #{path_for_printing}/#{name} must be '#{id}' (is '#{json['id']}')"
  end
  rest.post_rest(api_path, json)
  _make_child_entry(name, true)
end
delete(recurse) click to toggle source
# File lib/chef/chef_fs/file_system/data_bag_dir.rb, line 63
def delete(recurse)
  if !recurse
    raise Chef::ChefFS::FileSystem::MustDeleteRecursivelyError.new, "#{path_for_printing} must be deleted recursively"
  end
  begin
    rest.delete_rest(api_path)
  rescue Net::HTTPServerException
    if $!.response.code == "404"
      raise Chef::ChefFS::FileSystem::NotFoundError.new($!), "#{path_for_printing} not found"
    end
  end
end
dir?() click to toggle source
# File lib/chef/chef_fs/file_system/data_bag_dir.rb, line 33
def dir?
  exists?
end
exists?() click to toggle source
# 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() click to toggle source
# 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, "#{path_for_printing} not found"
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.