Class: FakePlugger::DeliveryMethod
- Inherits:
-
MailPlugger::DeliveryMethod
- Object
- MailPlugger::DeliveryMethod
- FakePlugger::DeliveryMethod
- Defined in:
- lib/fake_plugger/delivery_method.rb
Constant Summary
Constants included from MailPlugger::MailHelper
MailPlugger::MailHelper::DELIVERY_SETTINGS_KEYS, MailPlugger::MailHelper::SENDING_METHODS
Instance Method Summary collapse
-
#deliver!(message) ⇒ Mail::Message/Hash
Using SMTP: Mock send message via SMTP protocol if the ‘delivery_settings’ contains a ‘smtp_settings’ key and the value is a hash with the settings.
-
#initialize(options = {}) ⇒ DeliveryMethod
constructor
Initialize FakePlugger delivery method attributes.
Methods included from MailPlugger::MailHelper
#check_version_of, #client, #default_data, #default_delivery_system_get, #delivery_data, #delivery_options, #delivery_system, #delivery_system_value_check, #exclude_delivey_settings_keys?, #extract_attachments, #extract_keys, #extract_keys_from_other_variables, #mail_field_value, #message_field_value_from, #need_delivery_system?, #option_value_from, #send_via_smtp?, #sending_method_get, #settings
Constructor Details
#initialize(options = {}) ⇒ DeliveryMethod
Initialize FakePlugger delivery method attributes. If we are using MailPlugger.plug_in method, then these attributes can be nil, if not then we should set these attributes.
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/fake_plugger/delivery_method.rb', line 38 def initialize( = {}) super @debug = [:debug] = [:raw_message] @response = [:response] @use_mail_grabber = [:use_mail_grabber] end |
Instance Method Details
#deliver!(message) ⇒ Mail::Message/Hash
Using SMTP: Mock send message via SMTP protocol if the ‘delivery_settings’ contains a ‘smtp_settings’ key and the value is a hash with the settings.
Using API: Mock send message with the given client if the message parameter is a Mail::Message object. If ‘response’ parameter is nil, then it will extract this information from the Mail::Message object which was provided in the ‘delivery_options’. After that it generates a hash with these data and returns with the provided client class which has a ‘deliver’ method, but it won’t call the ‘deliver’ method. If the ‘response’ parameter is a hash with ‘return_delivery_data: true’ then it will return with the extracted delivery data.
If the ‘response’ parameter is not nil, then returns with that given data without call any other methods. Except if ‘debug’ is true. In this case, it will call those methods which are calling in normal operation as well. If ‘debug’ is true, then it prints out some debug information. If ‘raw_message’ is true, then it prints out raw message. If ‘use_mail_grabber’ is true, then it stores the message in a database.
151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/fake_plugger/delivery_method.rb', line 151 def deliver!() unless .is_a?(Mail::Message) raise MailPlugger::Error::WrongParameter, 'The given parameter is not a Mail::Message' end = update_settings return_with_response end |