Created
April 2, 2010 20:27
-
-
Save agibralter/353664 to your computer and use it in GitHub Desktop.
A tweak to Culerity's persistent delivery
This file contains 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
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