Class: T::Mailer::DeliveryMethod
- Inherits:
-
Object
- Object
- T::Mailer::DeliveryMethod
- Includes:
- Helper
- Defined in:
- lib/t/mailer/delivery_method.rb
Instance Attribute Summary collapse
-
#settings ⇒ Object
readonly
Returns the value of attribute settings.
Instance Method Summary collapse
-
#deliver!(message) ⇒ Object
Check that the delivery system is provided.
-
#initialize(options = {}) ⇒ DeliveryMethod
constructor
Set settings with the required credentials for the API, but allow to call the delivery method without it.
Methods included from Helper
#check_api_defined, #check_settings, #check_version_of, #field_value, #get_value_from, #using_gem
Constructor Details
#initialize(options = {}) ⇒ DeliveryMethod
Set settings with the required credentials for the API, but allow to call the delivery method without it. In that case it will set that up with the default. If credentials has been added then it will override the default credentials.
14 15 16 17 18 19 20 21 |
# File 'lib/t/mailer/delivery_method.rb', line 14 def initialize( = {}) @settings = { aws_access_key_id: T::Mailer.configuration.aws_access_key_id, aws_default_region: T::Mailer.configuration.aws_default_region, aws_secret_access_key: T::Mailer.configuration.aws_secret_access_key, sparkpost_api_key: T::Mailer.configuration.sparkpost_api_key, }.merge!() end |
Instance Attribute Details
#settings ⇒ Object (readonly)
Returns the value of attribute settings.
6 7 8 |
# File 'lib/t/mailer/delivery_method.rb', line 6 def settings @settings end |
Instance Method Details
#deliver!(message) ⇒ Object
Check that the delivery system is provided. If delivery system is missing it will raise error. If delivery system was provided then it will call the given delivery system with the message. If the provided delivery system does not exist the it will raise error.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/t/mailer/delivery_method.rb', line 29 def deliver!() delivery_system = get_value_from(["delivery_system"]) if delivery_system.nil? fail Error::WrongDeliverySystem, "Delivery system is missing." end case delivery_system when "ses" DeliverySystem::AwsSes.new(settings).deliver() when "sparkpost" DeliverySystem::SparkPost.new(settings).deliver() else fail Error::WrongDeliverySystem, "The given delivery system is not supported." end end |