Class: Gluer::FilePool

Inherits:
Object
  • Object
show all
Defined in:
lib/gluer/file_pool.rb

Instance Method Summary collapse

Constructor Details

#initializeFilePool

Returns a new instance of FilePool.



7
8
9
# File 'lib/gluer/file_pool.rb', line 7

def initialize
  clear
end

Instance Method Details

#clearObject



15
16
17
# File 'lib/gluer/file_pool.rb', line 15

def clear
  @files = Hash.new
end

#get(path) ⇒ Object



11
12
13
# File 'lib/gluer/file_pool.rb', line 11

def get(path)
  files[path]
end

#updateObject



19
20
21
22
23
24
25
26
27
# File 'lib/gluer/file_pool.rb', line 19

def update
  updated_file_paths = Set.new(collect)
  (current_file_paths - updated_file_paths).each do |old_path|
    files.delete(old_path).unload
  end
  updated_file_paths.each do |path|
    (files[path] ||= File.new(path)).reload
  end
end