module Culerity::PersistentDelivery

Constants

DELIVERIES_PATH

Public Class Methods

clear_deliveries() click to toggle source
# File lib/culerity/persistent_delivery.rb, line 18
def self.clear_deliveries
  FileUtils.rm_f DELIVERIES_PATH
end
deliveries() click to toggle source
# File lib/culerity/persistent_delivery.rb, line 11
def self.deliveries
  return [] unless File.exist?(DELIVERIES_PATH)
  File.open(DELIVERIES_PATH,'r') do |f| 
    Marshal.load(f)
  end
end
included(base) click to toggle source
# File lib/culerity/persistent_delivery.rb, line 9
def self.included(base)
  base.class_eval do
    def self.deliveries
      return [] unless File.exist?(DELIVERIES_PATH)
      File.open(DELIVERIES_PATH,'r') do |f| 
        Marshal.load(f)
      end
    end 
  
    def self.clear_deliveries
      FileUtils.rm_f DELIVERIES_PATH
    end
  end
end

Public Instance Methods

perform_delivery_persistent(mail) click to toggle source
# File lib/culerity/persistent_delivery.rb, line 24
def perform_delivery_persistent(mail)
  deliveries = self.class.deliveries << mail
  File.open(DELIVERIES_PATH,'w') do |f|
    f << Marshal.dump(deliveries)
  end
end