Skip to content

Instantly share code, notes, and snippets.

@agibralter
Created April 2, 2010 20:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agibralter/353664 to your computer and use it in GitHub Desktop.
Save agibralter/353664 to your computer and use it in GitHub Desktop.
A tweak to Culerity's persistent delivery
require 'fileutils'
module Culerity
module PersistentDelivery
DELIVERIES_PATH = File.join(Rails.root, 'tmp', 'am_deliveries.cache')
def self.included(base)
base.class_eval do
def self.deliveries
File.exist?(DELIVERIES_PATH) ? File.open(DELIVERIES_PATH, 'r') { |f| Marshal.load(f) } : []
end
def self.clear_deliveries
FileUtils.rm_f(DELIVERIES_PATH) if File.exist?(DELIVERIES_PATH)
end
end
end
def perform_delivery_persistent(mail)
deliveries = self.class.deliveries << mail
File.open(DELIVERIES_PATH, 'w') do |f|
f << Marshal.dump(deliveries)
end
end
end
end
ActionMailer::Base.send(:include, Culerity::PersistentDelivery)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment