Module: Glue::Sweeper
- Includes:
- Aspects
- Defined in:
- lib/glue/sweeper.rb
Overview
This module adds cleanup functionality to managed classes. Override and implement sweep_affected. Typically used to cleanup output caching files from the filesystem. But you can also use it to clean up temp objects in the database or other temp files. – FIXME: find a better name. ++
Class Method Summary collapse
-
.expire(name, klass, relative = false) ⇒ Object
Expires (deletes) a cached page from the file system.
Class Method Details
.expire(name, klass, relative = false) ⇒ Object
Expires (deletes) a cached page from the file system.
Input
-
relative = if set to true, prepends the controller mount path.
– FIXME: replace with ‘extend Nitro::Caching::Output’ ? this way we wont have to sync the same code in two different places. If you change this method, don’t forget the Caching::Output expire method.
++
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/glue/sweeper.rb', line 40 def self.expire(name, klass, relative = false) if relative and controller = klass.ann.self[:controller] filename = "#{Server.public_root}/#{controller.mount_path}/#{name}.html".squeeze('/') else filename = "#{Server.public_root}/#{name}.html".squeeze('/') end Logger.debug "Sweeper expired cache file '#{filename}'" if $DBG FileUtils.rm_rf(filename) rescue Object => ex # ignore any error. end |