Skip to content

Instantly share code, notes, and snippets.

@laser
Last active January 4, 2016 10:19
Show Gist options
  • Save laser/8607820 to your computer and use it in GitHub Desktop.
Save laser/8607820 to your computer and use it in GitHub Desktop.
prunable b
# 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