Class: ChefFS::FileSystem::MultiplexedDir
Instance Attribute Summary collapse
Attributes inherited from BaseFSObject
#name, #parent, #path
Instance Method Summary
collapse
Methods inherited from BaseFSDir
#child, #dir?
#chef_object, #child, #compare_to, #delete, #dir?, #exists?, #path_for_printing, #read, #root, #write
Constructor Details
#initialize(*multiplexed_dirs) ⇒ MultiplexedDir
Returns a new instance of MultiplexedDir.
7
8
9
10
|
# File 'lib/chef_fs/file_system/multiplexed_dir.rb', line 7
def initialize(*multiplexed_dirs)
@multiplexed_dirs = multiplexed_dirs.flatten
super(@multiplexed_dirs[0].name, @multiplexed_dirs[0].parent)
end
|
Instance Attribute Details
#multiplexed_dirs ⇒ Object
Returns the value of attribute multiplexed_dirs.
12
13
14
|
# File 'lib/chef_fs/file_system/multiplexed_dir.rb', line 12
def multiplexed_dirs
@multiplexed_dirs
end
|
Instance Method Details
#can_have_child?(name, is_dir) ⇒ Boolean
37
38
39
|
# File 'lib/chef_fs/file_system/multiplexed_dir.rb', line 37
def can_have_child?(name, is_dir)
write_dir.can_have_child?(name, is_dir)
end
|
#children ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/chef_fs/file_system/multiplexed_dir.rb', line 18
def children
@children ||= begin
result = []
seen = {}
multiplexed_dirs.each do |dir|
dir.children.each do |child|
if seen[child.name]
Chef::Log.warn("Child with name '#{child.name}' found in multiple directories: #{seen[child.name].path_for_printing} and #{child.path_for_printing}")
else
result << child
seen[child.name] = child
end
end
end
result
end
end
|
#create_child(name, file_contents = nil) ⇒ Object
41
42
43
44
|
# File 'lib/chef_fs/file_system/multiplexed_dir.rb', line 41
def create_child(name, file_contents = nil)
@children = nil
write_dir.create_child(name, file_contents)
end
|
#write_dir ⇒ Object
14
15
16
|
# File 'lib/chef_fs/file_system/multiplexed_dir.rb', line 14
def write_dir
multiplexed_dirs[0]
end
|