Class: Mailgems::DeliveryMethod

Inherits:
Object
  • Object
show all
Defined in:
lib/mailgems/delivery_method.rb

Defined Under Namespace

Classes: InvalidOption

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ DeliveryMethod

Returns a new instance of DeliveryMethod.

Raises:



12
13
14
15
16
17
18
19
20
# File 'lib/mailgems/delivery_method.rb', line 12

def initialize(options = {})
  options[:host] = "https://www.mailgems.com"
  options[:api_key] ||= Mailgems.configuration.api_key
  options[:sandbox] ||= Mailgems.configuration.sandbox

  raise InvalidOption, "Api Key is required" if options[:api_key].nil?

  self.settings = options
end

Instance Attribute Details

#settingsObject

Returns the value of attribute settings.



10
11
12
# File 'lib/mailgems/delivery_method.rb', line 10

def settings
  @settings
end

Instance Method Details

#deliver!(mail) ⇒ Object



22
23
24
25
26
# File 'lib/mailgems/delivery_method.rb', line 22

def deliver!(mail)
  validate_mail!(mail)
  Message.new(mail, settings).send
  Launchy.open("#{settings[:host]}/sandbox") if settings[:sandbox]
end