Class: Hanami::Mailer::Delivery::Result
- Inherits:
-
Object
- Object
- Hanami::Mailer::Delivery::Result
- Defined in:
- lib/hanami/mailer/delivery/result.rb
Overview
Represents the outcome of a message delivery attempt.
This is the base class for delivery results. Delivery methods return an instance of this class (or a subclass) from their #call method. Third-party delivery methods are encouraged to subclass this and add any service-specific attributes they need.
Instance Attribute Summary collapse
-
#error ⇒ Exception?
readonly
The exception raised during delivery, if delivery failed.
-
#message ⇒ Hanami::Mailer::Message
readonly
The prepared message that was (or was attempted to be) delivered.
-
#response ⇒ Object?
readonly
The raw return value from the delivery method, if any.
Instance Method Summary collapse
-
#initialize(message:, response: nil, success: true, error: nil) ⇒ Result
constructor
private
A new instance of Result.
-
#success? ⇒ Boolean
Returns true if delivery succeeded.
Constructor Details
#initialize(message:, response: nil, success: true, error: nil) ⇒ Result
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Result.
64 65 66 67 68 69 |
# File 'lib/hanami/mailer/delivery/result.rb', line 64 def initialize(message:, response: nil, success: true, error: nil) @message = @response = response @success = success @error = error end |
Instance Attribute Details
#error ⇒ Exception? (readonly)
The exception raised during delivery, if delivery failed.
56 57 58 |
# File 'lib/hanami/mailer/delivery/result.rb', line 56 def error @error end |
#message ⇒ Hanami::Mailer::Message (readonly)
The prepared message that was (or was attempted to be) delivered.
38 39 40 |
# File 'lib/hanami/mailer/delivery/result.rb', line 38 def @message end |
#response ⇒ Object? (readonly)
The raw return value from the delivery method, if any.
For SMTP delivery this will be the Mail::Message object. For test delivery this will be nil. The exact type is delivery-method-specific; consult the documentation for the delivery method you are using.
49 50 51 |
# File 'lib/hanami/mailer/delivery/result.rb', line 49 def response @response end |
Instance Method Details
#success? ⇒ Boolean
Returns true if delivery succeeded.
76 77 78 |
# File 'lib/hanami/mailer/delivery/result.rb', line 76 def success? @success end |