Last active
January 4, 2016 10:19
-
-
Save laser/8607820 to your computer and use it in GitHub Desktop.
prunable b
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/util/prunable.rb | |
class Prunable | |
def self.from_assets(assets) | |
assets.select &method(:is_prunable?) | |
end | |
def self.is_prunable?(asset) | |
asset.created_at < Date.today - 30 | |
end | |
end | |
# app/jobs/s3_pruner.rb | |
class S3FilePruner < JobProcessor | |
def process_job | |
Prunable.from_assets(Image.all).each do |image| | |
S3Object.delete image.s3_object_name, image.s3_bucket_name | |
image.destroy | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment