Class: Chef::ChefFS::FileSystem::ChefServer::AclDir

Inherits:
BaseFSDir show all
Defined in:
lib/chef/chef_fs/file_system/chef_server/acl_dir.rb

Direct Known Subclasses

CookbooksAclDir, PoliciesAclDir

Instance Attribute Summary

Attributes inherited from BaseFSObject

#name, #parent, #path

Instance Method Summary collapse

Methods inherited from BaseFSDir

#dir?, #empty?, #initialize

Methods inherited from BaseFSObject

#chef_object, #child, #compare_to, #delete, #dir?, #exists?, #initialize, #path_for_printing, #read, #root, #write

Constructor Details

This class inherits a constructor from Chef::ChefFS::FileSystem::BaseFSDir

Instance Method Details

#api_pathObject



28
29
30
# File 'lib/chef/chef_fs/file_system/chef_server/acl_dir.rb', line 28

def api_path
  parent.parent.child(name).api_path
end

#can_have_child?(name, is_dir) ⇒ Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/chef/chef_fs/file_system/chef_server/acl_dir.rb', line 37

def can_have_child?(name, is_dir)
  !is_dir
end

#childrenObject



41
42
43
44
45
46
47
48
# File 'lib/chef/chef_fs/file_system/chef_server/acl_dir.rb', line 41

def children
  if @children.nil?
    # Grab the ACTUAL children (/nodes, /containers, etc.) and get their names
    names = parent.parent.child(name).children.map { |child| child.dir? ? "#{child.name}.json" : child.name }
    @children = names.map { |name| make_child_entry(name, true) }
  end
  @children
end

#create_child(name, file_contents) ⇒ Object



50
51
52
# File 'lib/chef/chef_fs/file_system/chef_server/acl_dir.rb', line 50

def create_child(name, file_contents)
  raise OperationNotAllowedError.new(:create_child, self, nil, "ACLs can only be updated, and can only be created when the corresponding object is created.")
end

#data_handlerObject



54
55
56
# File 'lib/chef/chef_fs/file_system/chef_server/acl_dir.rb', line 54

def data_handler
  parent.data_handler
end

#make_child_entry(name, exists = nil) ⇒ Object



32
33
34
35
# File 'lib/chef/chef_fs/file_system/chef_server/acl_dir.rb', line 32

def make_child_entry(name, exists = nil)
  result = @children.find { |child| child.name == name } if @children
  result || AclEntry.new(name, self, exists)
end

#restObject



58
59
60
# File 'lib/chef/chef_fs/file_system/chef_server/acl_dir.rb', line 58

def rest
  parent.rest
end