Class: Gluer::FilePool
- Inherits:
-
Object
- Object
- Gluer::FilePool
- Defined in:
- lib/gluer/file_pool.rb
Instance Method Summary collapse
- #clear ⇒ Object
- #get(path) ⇒ Object
-
#initialize ⇒ FilePool
constructor
A new instance of FilePool.
- #update ⇒ Object
Constructor Details
#initialize ⇒ FilePool
Returns a new instance of FilePool.
7 8 9 |
# File 'lib/gluer/file_pool.rb', line 7 def initialize clear end |
Instance Method Details
#clear ⇒ Object
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 |
#update ⇒ Object
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 |