Module: PathMapper::Helper::Storage
- Included in:
- PathMapper::Helpers
- Defined in:
- lib/path_mapper/helper/storage.rb
Instance Method Summary collapse
- #delete_storage_branch(pathname) ⇒ Object
- #deleted_files ⇒ Object
- #storage ⇒ Object
- #storage_file_delete(pathname) ⇒ Object
- #storage_file_tree(pathname) ⇒ Object
- #storage_tree(pathname) ⇒ Object
Instance Method Details
#delete_storage_branch(pathname) ⇒ Object
30 31 32 33 |
# File 'lib/path_mapper/helper/storage.rb', line 30 def delete_storage_branch(pathname) self.storage_file_delete(pathname) self.storage.select {|k,v| k.to_s.start_with? pathname.to_s }.each {|k,v| self.storage_file_delete(k) } end |
#deleted_files ⇒ Object
8 9 10 |
# File 'lib/path_mapper/helper/storage.rb', line 8 def deleted_files self.storage[:deleted_files] ||= [] end |
#storage ⇒ Object
4 5 6 |
# File 'lib/path_mapper/helper/storage.rb', line 4 def storage Thread.current[:dry_storage] ||= {} end |
#storage_file_delete(pathname) ⇒ Object
25 26 27 28 |
# File 'lib/path_mapper/helper/storage.rb', line 25 def storage_file_delete(pathname) self.deleted_files << pathname self.storage.delete(pathname) end |
#storage_file_tree(pathname) ⇒ Object
20 21 22 23 |
# File 'lib/path_mapper/helper/storage.rb', line 20 def storage_file_tree(pathname) self.storage[pathname] = File.read(pathname) storage_tree(pathname.parent) end |
#storage_tree(pathname) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/path_mapper/helper/storage.rb', line 12 def storage_tree(pathname) path = pathname while path.to_s != '/' self.storage[path] = nil path = path.parent end end |