Class: Mailpeek::Delivery
- Inherits:
-
Object
- Object
- Mailpeek::Delivery
- Includes:
- Mail::CheckDeliveryParams
- Defined in:
- lib/mailpeek/delivery.rb
Overview
Public: Delivery
Defined Under Namespace
Classes: InvalidOption
Instance Attribute Summary collapse
-
#settings ⇒ Object
Returns the value of attribute settings.
Instance Method Summary collapse
- #deliver!(mail) ⇒ Object
-
#initialize(options = {}) ⇒ Delivery
constructor
A new instance of Delivery.
Constructor Details
#initialize(options = {}) ⇒ Delivery
Returns a new instance of Delivery.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/mailpeek/delivery.rb', line 14 def initialize( = {}) [:location] ||= Mailpeek.configuration.location [:limit] ||= Mailpeek.configuration.limit [:limit] = [:limit].to_i if [:location].nil? raise InvalidOption, 'A location option is required when using Mailpeek' end # rubocop:disable Style/GuardClause if [:limit].nil? raise InvalidOption, 'A limit option is required when using Mailpeek' elsif [:limit] <= 0 raise InvalidOption, 'A limit option is an invalid number' end # rubocop:enable Style/GuardClause self.settings = end |
Instance Attribute Details
#settings ⇒ Object
Returns the value of attribute settings.
12 13 14 |
# File 'lib/mailpeek/delivery.rb', line 12 def settings @settings end |
Instance Method Details
#deliver!(mail) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/mailpeek/delivery.rb', line 35 def deliver!(mail) check_delivery_params(mail) if respond_to?(:check_delivery_params) clean_up basepath = File.join(settings[:location], Time.now.to_i.to_s) save_email(mail, basepath) return true unless mail..any? (mail, basepath) end |