Class: Mailgems::Message

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

Constant Summary collapse

ERROR_MSG =
'%s configuration must be given'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mail, settings) ⇒ Message

Returns a new instance of Message.

Raises:

  • (ArgumentError)


8
9
10
11
12
13
14
# File 'lib/mailgems/message.rb', line 8

def initialize(mail, settings)
  @mail = mail
  @api_key = settings[:api_key]
  @sandbox = settings[:sandbox]

  raise ArgumentError, ERROR_MSG % 'Api key' unless @api_key
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



5
6
7
# File 'lib/mailgems/message.rb', line 5

def api_key
  @api_key
end

#mailObject (readonly)

Returns the value of attribute mail.



5
6
7
# File 'lib/mailgems/message.rb', line 5

def mail
  @mail
end

#sandboxObject (readonly)

Returns the value of attribute sandbox.



5
6
7
# File 'lib/mailgems/message.rb', line 5

def sandbox
  @sandbox
end

Instance Method Details

#sendObject



16
17
18
# File 'lib/mailgems/message.rb', line 16

def send
  Mail.new(api_key: api_key).send_mail(params)
end