Class: MailRoom::Mailbox
- Inherits:
-
Struct
- Object
- Struct
- MailRoom::Mailbox
- Defined in:
- lib/mail_room/mailbox.rb
Overview
Holds configuration for each of the email accounts we wish to monitor
and deliver email to when new emails arrive over imap
Constant Summary collapse
- DEFAULTS =
Default attributes for the mailbox configuration
{ :search_command => 'UNSEEN', :delivery_method => 'postback', :host => 'imap.gmail.com', :port => 993, :ssl => true, :delete_after_delivery => false, :delivery_options => {} }
Instance Method Summary collapse
-
#deliver(message) ⇒ Object
deliver the imap email message.
-
#delivery_klass ⇒ Object
move to a mailbox deliverer class?.
-
#initialize(attributes = {}) ⇒ Mailbox
constructor
Store the configuration and require the appropriate delivery method.
Constructor Details
#initialize(attributes = {}) ⇒ Mailbox
Store the configuration and require the appropriate delivery method
36 37 38 39 40 |
# File 'lib/mail_room/mailbox.rb', line 36 def initialize(attributes={}) super(*DEFAULTS.merge(attributes).values_at(*members)) require_relative("./delivery/#{(delivery_method)}") end |
Instance Method Details
#deliver(message) ⇒ Object
deliver the imap email message
60 61 62 63 64 65 |
# File 'lib/mail_room/mailbox.rb', line 60 def deliver() = .attr['RFC822'] return true unless delivery_klass.new().deliver() end |
#delivery_klass ⇒ Object
move to a mailbox deliverer class?
43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/mail_room/mailbox.rb', line 43 def delivery_klass case delivery_method when "noop" Delivery::Noop when "logger" Delivery::Logger when "letter_opener" Delivery::LetterOpener when "sidekiq" Delivery::Sidekiq else Delivery::Postback end end |