Module: Culerity::PersistentDelivery

Defined in:
lib/culerity/persistent_delivery.rb

Constant Summary collapse

DELIVERIES_PATH =
File.join(RAILS_ROOT, 'tmp', 'action_mailer_acceptance_deliveries.cache')

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# 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

Instance Method Details

#perform_delivery_persistent(mail) ⇒ Object



24
25
26
27
28
29
# 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