Class: Mail::SingleFileDelivery::Agent

Inherits:
Object
  • Object
show all
Defined in:
lib/mail-single_file_delivery.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(settings = {}) ⇒ Agent

Returns a new instance of Agent.



8
9
10
11
12
13
14
# File 'lib/mail-single_file_delivery.rb', line 8

def initialize(settings={})
  self.settings = {:filename => '/tmp/mail-single_file'}.merge! settings
  filename = self.settings[:filename]
  mode = File.pipe?(filename) ? 'a+' : 'w'
  @fd = File.open(filename, mode) \
    or raise "Cannot open #{filename} for writing" # just being safe
end

Instance Attribute Details

#settingsObject

Returns the value of attribute settings.



6
7
8
# File 'lib/mail-single_file_delivery.rb', line 6

def settings
  @settings
end

Instance Method Details

#deliver!(mail) ⇒ Object



16
17
18
19
# File 'lib/mail-single_file_delivery.rb', line 16

def deliver!(mail)
  @fd.write mail.encoded + "\r\n\r\n"
  @fd.flush
end