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

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

Direct Known Subclasses

CookbooksAclDir

Instance Attribute Summary

Attributes inherited from BaseFSObject

#name, #parent, #path

Instance Method Summary collapse

Methods inherited from BaseFSDir

#dir?, #initialize

Methods inherited from BaseFSObject

#chef_object, #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



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

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/acl_dir.rb', line 37

def can_have_child?(name, is_dir)
  name =~ /\.json$/ && !is_dir
end

#child(name) ⇒ Object



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

def child(name)
  result = @children.select { |child| child.name == name }.first if @children
  result ||= can_have_child?(name, false) ?
             AclEntry.new(name, self) : NonexistentFSObject.new(name, self)
end

#childrenObject



41
42
43
44
45
46
47
48
# File 'lib/chef/chef_fs/file_system/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| AclEntry.new(name, self, true) }
  end
  @children
end

#create_child(name, file_contents) ⇒ Object

Raises:



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

def create_child(name, file_contents)
  raise OperationNotAllowedError.new(:create_child, self), "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/acl_dir.rb', line 54

def data_handler
  parent.data_handler
end

#restObject



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

def rest
  parent.rest
end